chicken and egg problem in linker script

Roger Miller Roger_M1@VERIFONE.com
Wed Nov 12 19:04:00 GMT 2003


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?



More information about the Gcc-help mailing list