This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

chicken and egg problem in linker script


I seem to have run into a chicken-and-egg problem in ld.  Basically
I need to build an executable file for an ARM embedded system with
the following layout:

    .text at a fixed address
    read-only copy of .data (copied to RAM at startup)
    padding to page boundary (1024-byte page size)
    .data (RAM)
    .bss (RAM)

The problem is that the address of the .data section depends on its
size, because of the read-only copy of it which follows .text.  But
determining the size requires linking it, and ld won't do this without
a constant address.

My inelegant work-around is to do a preliminary link with .data at a
dummy address, use objdump to get the section size, calculate the actual
.data address, and link again.  Is something like this the only way to
handle the problem, or am I overlooking some linker script feature that
could handle this in a single pass?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]