Help needed - defining the output section order

Simon Kissel scamp@untergrund.net
Mon Aug 22 13:11:00 GMT 2005


Hi Nick,

NC> Yes - use the SECTIONS command in the linker script...

In this case it would keep it in the order as the sections are listed
in the SECTIONS command? That would be cool.

NC> Ah well, that is because your new linker script is too simple.  There is
NC> a section in the linker documentation that talks about this problem:

NC>    When producing an ELF output file, if the linker script uses
NC>    the SIZEOF_HEADERS builtin function, the linker must compute
NC>    the number of program headers before it has determined all
NC>    the section addresses and sizes.  If the linker later
NC>    discovers that it needs additional program headers, it will
NC>    report an error "not enough room for program headers".  To
NC>    avoid this error, you must avoid using the SIZEOF_HEADERS
NC>    function, or you must rework your linker script to avoid
NC>    forcing the linker to use additional program headers, or
NC>    you must define the program headers yourself using the
NC>    PHDRS command.

...well, that part of the docs doesn't say "If you use the SECTIONS
command, generation of program headers will fail" ;)

(But this is a completely different topic)

NC> So what you probably need to do is to add a PHDRS command to your linker
NC> script.

Ok, that looks really complex. But if there is no other way, I'll try
to go and survive that route.

NC> Plus what you probably really want to do is to find out the default
NC> script used by the linker (by running ld --verbose) and then take the
NC> SECTIONS command from there and merge in your fpc.* sections. The
NC> SECTIONS command in the default script will probably be a lot more
NC> comprehensive than the one that you are currently using.

I'll try that first and report back.

Thank you,

Simon





More information about the Binutils mailing list