Bug 185096

Summary: ld --as-needed causes either crash or BFD internal error
Product: [Fedora] Fedora Reporter: Dmitry V. Levin <ldv>
Component: binutilsAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: rawhide   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-05-09 10:58:06 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Dmitry V. Levin 2006-03-10 11:39:46 EST
ld --as-needed sometimes fails with internal error.
I constructed 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
[last two lines repeated many times]
/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

Tested with binutils-2.16.91.0.6-4 and gcc-c++-4.1.0-3 on i686 and x86_64.
Comment 1 Dmitry V. Levin 2006-03-13 18:44:10 EST
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]
Comment 2 Dmitry V. Levin 2006-05-09 10:58:06 EDT
Fixed upstream in 2.17.50.0.1-1.