'ld' crashes for large shared objects

'ld' crashes for large shared objects

Post by Ken Taiyo Takusagaw » Sat, 25 Sep 1999 04:00:00



I'm trying to link together many .o files into a large .so file
(approx 60MB) on RH 6.0/i686.

Here is the command line:

g++ -shared -fpic *.o -o lib.so

I watch with 'top' as the linking progresses, and as soon as the
amout of free "Mem" (not swap) dips to 0 (or actually 3000K or
so), I get lots of errors in the form:

/usr/bin/ld: bfd assertion fail elf32-i386.c:621
/usr/bin/ld: bfd assertion fail elf32-i386.c:621
/usr/bin/ld: bfd assertion fail elf32-i386.c:621
/usr/bin/ld: bfd assertion fail elf32-i386.c:1414

and the .so file is not produced.  I suspect the loader is
running out of memory.

So it seems 'ld' doesn't use virtual memory?

Getting more RAM is not an option for me, so does anyone have
suggestions on how I might be able to link this thing?

--ken

 
 
 

'ld' crashes for large shared objects

Post by Peter Samuels » Sun, 26 Sep 1999 04:00:00



Quote:> I watch with 'top' as the linking progresses, and as soon as the
> amout of free "Mem" (not swap) dips to 0 (or actually 3000K or
> so), I get lots of errors in the form:
> /usr/bin/ld: bfd assertion fail elf32-i386.c:621

My guess is, your binutils is buggy.  What version of binutils are you
running ("ld --version")?  It appears not always to be checking for the
out-of-memory condition....

Quote:> So it seems 'ld' doesn't use virtual memory?

I can't imagine how it could *not* use virtual memory.  Applications
have no say in the matter.  The kernel does it all completely
transparently (aside from a slowdown...).  The fact that Linux doesn't
seem to be eating into your swap space (or is it?  See /proc/meminfo)
is puzzling.

Quote:> Getting more RAM is not an option for me, so does anyone have
> suggestions on how I might be able to link this thing?

Try linking in stages.  I.e. make bigger object files out of your small
object files:

        $(LD) -r -o dir1.o dir1/*.o
        $(LD) -r -o dir2.o dir2/*.o
        $(LD) -r -o dir3.o dir3/*.o
        $(CC) $(LDFLAGS) dir1.o dir2.o dir3.o $(LDLIBS)

If the last stage still needs more memory than you have, try other ld
flags for linking the dir*.o files: --discard-locals, --discard-all,
--strip-debug (or don't use "cc -g").  These three flags will reduce
the number of symbols ld will have to read in for the last big link
job.  Hope this helps.

--
Peter Samuelson
<sampo.creighton.edu!psamuels>

 
 
 

1. what does 'ld: Output file requires shared library `libc.so.4'' mean?

I upgraded (downgraded?) to Slackware 1.2.2 and got the gcc 2.6.3 package
installed. However I'm having a problem linking with the debug option '-g'

when I do...

gcc -g -o t t.c -lm   (where t.c is some cheesy program)

I get...

ld: Output file requires shared library `libc.so.4'
gcc: Internal compiler error: program ld got fatal signal 6

Anybody know what file/link I am missing and how do I go about fixing this?

thanks,

- Jeff Wiegley

2. kde 3.0 upgrade 3.0.4

3. Linking C and C++ code object files with 'ld'?

4. Persistant CGI program's on a Apache server

5. Error 'Shared object "libssl.so.3" not found' when using mail

6. XFree86 1.3: Success with Cirrus

7. LinuxPPC99: 'INIT: ld ''x'' respawning too fast...'??

8. fdisk under Win95

9. warnings from 'ld' when building shared lib

10. ld: Output file requires shared library 'libc.so.4' : error

11. Using 'ld' to build an ELF SHARED LIBRARY

12. ld: Output file requires shared library 'libc.so.4'

13. /lib/ld: cache 'LD.SO.CACHE' is corrupt (or equivelent)