Defining a section that isn't file-backed

Nick Clifton nickc@redhat.com
Mon Feb 23 15:21:00 GMT 2004


Hi Mike,

> I've tried this but unfortunately get:
>
> gcc -o lds1 -Wl,-T,lds1.ldscript -lm -ldl -lncurses -lpthread -lssl -lpam -luuid -ltermcap lds1.c
> /usr/bin/ld: lds1: Not enough room for program headers (allocated 7, need 8)

Ah yes, the dreaded "not enough room for program headers" problem.
This is documented in the linker manual, so I suggest that you have a
look there.

The best solution is create and allocate your own program headers in
the linker script using the PHDR command.  I am attaching a script
which demonstrates this, although you will need to modify it for your
own circumstances.  For one thing it only defines 6 program headers
and according the linker error message you are going to need at least
8.  Also it does not map all sections to their proper segments (I was
lazy), so you will need to do that.  If you run "readelf -Sl" on your
program, without the .empty section, you should be able to find out
which segments you need and which sections should be allocated to
them.

Cheers
        Nick
        
-------------- next part --------------
A non-text attachment was scrubbed...
Name: script.t
Type: application/x-troff
Size: 6639 bytes
Desc: linker script
URL: <https://sourceware.org/pipermail/binutils/attachments/20040223/eb2e6609/attachment.t>


More information about the Binutils mailing list