Bug 7292 - ld fails to link large program
Summary: ld fails to link large program
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: binutils
Version: 6.1
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Cristian Gafton
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 1999-11-24 16:00 UTC by richieb
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2000-02-04 17:48:43 UTC

Attachments (Terms of Use)

Description richieb 1999-11-24 16:00:21 UTC
When I try to link a large program I get this error:

/usr/bin/ld: ./ise_testall: Not enough room for program headers (allocated
6, need 7)
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make: *** [ise_testall] Error 1

I'm not sure what this error means. When I reduce the size of the program
by recompiling with fewer internal tests, the link works OK.

Any suggestions?


Comment 1 Jim Kingdon 1999-11-29 17:39:59 UTC
Well, I can offer a partial answer (from a newer version of the binutils

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

The linker script in question is presumably one of the default ones
(in /usr/lib/ldscripts).  The question is what is in your test programs
to make them want that 7th program header (if I run "objdump -p /bin/ls"
it shows 6 program headers).  I'm not sure exactly what to look for, but
something along the lines of asm() statements with ".section" would
be one example of the kind of thing which might be relevant.

Comment 2 Cristian Gafton 2000-02-04 17:48:59 UTC
It looks like in this case a customized linker script is needed (like emacs
does). I suggest you report the problem to the binutils maintainers if you'd
like the default values changed.

Note You need to log in before you can comment on or make changes to this bug.