Re: chicken and egg problem in linker script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Roger Miller" <Roger_M1@xxxxxxxxxxxx> writes:

> 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?

This is not really the right mailing list for linker questions.
Better mailing lists would be bug-binutils@xxxxxxx or
binutils@xxxxxxxxxxxxxxx

In a linker script you can use SIZEOF to get the size of a section.
You can use that as a section address.

For an example of the type of thing you are trying to do, see:
    http://sources.redhat.com/binutils/docs-2.12/ld.info/Output-Section-LMA.html#Output%20Section%20LMA

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux