This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
chicken and egg problem in linker script
- From: "Roger Miller" <Roger_M1 at VERIFONE dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Wed, 12 Nov 2003 11:04:45 -0800
- Subject: 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?