Sources Bugzilla – Bug 437
LD core dumps on bad flags from gcc. Binutils 2.14 and 2.15
Last modified: 2004-10-16 11:08:47 UTC
[jason@home ~/c]$ more hello.c #include <stdio.h> int main() { printf ("hello world\n"); }; [jason@home ~/c]$ gcc -o run hello.c [jason@home ~/c]$ ./run hello world [jason@home ~/c]$ limit core unlimited [jason@home ~/c]$ gcc run hello.c collect2: ld terminated with signal 11 [Segmentation fault], core dumped (lots of noise deleted here) [jason@home ~/c]$ file core.3696 core.3696: ELF 32-bit LSB core file Intel 80386, version 1 (SYSV), SVR4-style, SVR4-style, from 'ld' [jason@home ~/c]$ which ld /usr/bin/ld [jason@home ~/c]$ /usr/bin/ld -v GNU ld version 2.14.90.0.7 20031029 [jason@home ~/c]$ gdb core.3696 /usr/bin/ld GNU gdb 6.0-2mdk (Mandrake Linux) (gdb) where #0 0x40042f74 in bfd_getl32 () from /usr/lib/libbfd-2.14.90.0.7.so #1 0x4005e257 in bfd_elf32_swap_reloc_in () from /usr/lib/libbfd-2.14.90.0.7.so (gdb) Checking the source code of binutils-2.14.90.0.7 I find in bfd/libbfd.c bfd_vma bfd_getl32 (const bfd_byte *addr) { unsigned long v; v = (unsigned long) addr[0]; v |= (unsigned long) addr[1] << 8; v |= (unsigned long) addr[2] << 16; v |= (unsigned long) addr[3] << 24; return v; } My first guess is that addr is NULL. I tried building binutils-2.15.92.0.2 and found a similar problem. An exercise I will repeat here in hopes that it provides additional information. [root@home bin]# pwd /usr/bin [root@home bin]# mv ld ld.old [root@home bin]# ln -s /home/jason/Development/bin/ld ld [root@home bin]# exit exit [jason@home bin]$ which ld /usr/bin/ld [jason@home bin]$ ld -v GNU ld version 2.15.92.0.2 20040927 Starting with an empty directory with hello.c again. [jason@home ~/c]$ gcc -o run hello.c [jason@home ~/c]$ ./run hello world [jason@home ~/c]$ gcc run hello.c collect2: ld terminated with signal 11 [Segmentation fault], core dumped (more noise deleted here) [jason@home ~/c]$ file core.3789 core.3789: ELF 32-bit LSB core file Intel 80386, version 1 (SYSV), SVR4-style, SVR4-style, from 'ld' [jason@home ~/c]$ gdb /usr/bin/ld core.3789 #0 bfd_getl32 (p=0x0) at libbfd.c:462 462 v |= (unsigned long) addr[1] << 8; (gdb) where #0 bfd_getl32 (p=0x0) at libbfd.c:462 #1 0x0808cc3a in elf_link_sort_relocs (abfd=0x8100228, info=0x80f5300, psec=0xbfffedbc) at elflink.c:5664 #2 0x08090396 in bfd_elf_final_link (abfd=0x8100228, info=0x80f5300) at elflink.c:8038 #3 0x0805a1d9 in ldwrite () at ldwrite.c:554 #4 0x08057f25 in main (argc=20, argv=0xbfffef54) at ldmain.c:484 (gdb) print p $1 = (const void *) 0x0 (gdb) print v $2 = 0 If additional information would be useful to resolve this problem, please don't hesitate to ask. Thanks.
http://sources.redhat.com/ml/binutils-cvs/2004-10/msg00079.html
(In reply to comment #1) > http://sources.redhat.com/ml/binutils-cvs/2004-10/msg00079.html I tried GNU ld version 041011 20041011 and ld now exits without a seg fault. This fix works well for me. Thanks for your assistance.
*** Bug 453 has been marked as a duplicate of this bug. ***