This is sources Bugzilla
Bugzilla Version 2.17.5
Bugzilla Bug 2434
  ld --as-needed causes either crash or BFD internal error Last modified: 2006-03-19 01:51:26
     Query page      Enter new bug
Bug#: 2434   Hardware:   Reporter: Dmitry V. Levin <ldv@altlinux.org>
Host: Target: Build:
Product:     Add CC:
Component:   Version:   CC:
Remove selected CCs
Status: RESOLVED   Priority:  
Resolution: FIXED   Severity:  
Assigned To: Alan Modra <amodra@bigpond.net.au>   Target Milestone:  
Summary:
Keywords:

Attachment Description Type Created Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 2434 depends on: Show dependency tree
Show dependency graph
Bug 2434 blocks:

Additional Comments:


Leave as RESOLVED FIXED
Reopen bug
Mark bug as VERIFIED

View Bug Activity   |   Format For Printing


Description:   Last confirmed: 2006-03-16 07:09 Opened: 2006-03-08 22:24
ld --as-needed sometimes fails with internal error.  I've succeeded to construct
a small testcase described below.

$ cat sample.cc 
extern void foo(void);
void my() { foo(); }

$ g++ -Wl,--no-as-needed -shared -Wall -fPIC sample.cc -lsupc++; echo rc=$?
rc=0

$ g++ -Wl,--as-needed -shared -Wall -fPIC sample.cc -lsupc++; echo rc=$?
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
/usr/bin/ld: BFD 2.16.91.0.6 20060212 internal error, aborting at elflink.c line
6453 in elf_link_output_extsym

/usr/bin/ld: Please report this bug.

collect2: ld returned 1 exit status
rc=1

------- Additional Comment #1 From Dmitry V. Levin 2006-03-10 23:39 -------
The test fails exactly the same way on FC-devel too (binutils-2.16.91.0.6-4,
gcc-c++-4.1.0-3).

------- Additional Comment #2 From Dmitry V. Levin 2006-03-13 23:44 -------
Even more simple test causes ld to crash in BFD:
$ g++ -shared -Wl,--as-needed -Wl,--whole-archive `gcc
-print-file-name=libsupc++.a` -Wl,--no-whole-archive
collect2: ld terminated with signal 11 [Segmentation fault]
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2317
/usr/bin/ld: BFD 2.16.91.0.6 20060212 assertion fail elflink.c:2318
[last two lines repeated 149 times]

$ gdb ld-debug
[...]
(gdb) r --as-needed --eh-frame-hdr -m elf_i386 -shared --whole-archive `gcc
-print-file-name=libsupc++.a` --no-whole-archive `gcc
-print-file-name=libstdc++.so`
[...]
Program received signal SIGSEGV, Segmentation fault.
0x00142c09 in bfd_putl32 (data=64168, p=0x0) at libbfd.c:706
706       addr[0] = data & 0xff;
(gdb) bt
#0  0x00142c09 in bfd_putl32 (data=64168, p=0x0) at libbfd.c:706
#1  0x001611b3 in bfd_elf32_swap_reloc_out (abfd=0x80aac28, src=0xbfffe1a0,
d=0x0) at elfcode.h:408
#2  0x0015d7e4 in elf_i386_relocate_section (output_bfd=0x80aac28,
info=0x80a0d20, input_bfd=0x81049f0, 
    input_section=0x8163e0c, contents=0x8317828 "\b", relocs=0x81767cc,
local_syms=0x81c1298, 
    local_sections=0x831edf8) at elf32-i386.c:2666
#3  0x0018061b in elf_link_input_bfd (finfo=0xbfffe460, input_bfd=0x81049f0) at
elflink.c:7142
#4  0x001828fb in bfd_elf_final_link (abfd=0x80aac28, info=0x80a0d20) at
elflink.c:8212
#5  0x08060a50 in ldwrite () at ldwrite.c:557
#6  0x0805e0b1 in main (argc=10, argv=0xbfffe594) at .././ld/ldmain.c:468

------- Additional Comment #3 From Alan Modra 2006-03-19 01:49 -------
*** Bug 2469 has been marked as a duplicate of this bug. ***

------- Additional Comment #4 From Alan Modra 2006-03-19 01:51 -------
http://sources.redhat.com/ml/binutils-cvs/2006-03/msg00079.html
http://sources.redhat.com/ml/binutils-cvs/2006-03/msg00087.html

     Query page      Enter new bug
Actions: New | Query | bug # | Reports | Requests   New Account | Log In