Bug 7292

Summary: ld fails to link large program
Product: [Retired] Red Hat Linux Reporter: richieb
Component: binutilsAssignee: Cristian Gafton <gafton>
Status: CLOSED WONTFIX QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-02-04 17:48:43 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

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.