Created attachment 6423 [details] A testcase On Linux/x86-64, this testccase causes: [hjl@gnu-6 new]$ g++ mv1.o -L. -B./ ./ld: BFD (GNU Binutils) 2.22.52.20120525 assertion fail /export/gnu/import/git/binutils/bfd/linker.c:641 collect2: ld returned 1 exit status [hjl@gnu-6 new]$
A small testcase: [hjl@gnu-6 pr14170]$ cat x.c extern int foo; extern int bar; int _start () { return foo + bar; } [hjl@gnu-6 pr14170]$ cat y.c int foo __attribute ((visibility("hidden"))); int bar = 1; [hjl@gnu-6 pr14170]$ cat foo.c void foo () {} [hjl@gnu-6 pr14170]$ make cc -c -o x.o x.c cc -shared -o libfoo.so -fPIC foo.c cc -c -o y.o y.c ./ld -o x x.o libfoo.so y.o ./ld: BFD (GNU Binutils) 2.22.52.20120525 assertion fail /export/gnu/import/git/binutils/bfd/linker.c:641 make: *** [x] Error 1 [hjl@gnu-6 pr14170]$
Created attachment 6424 [details] partial fix This fixes the assert, but doesn't completely cure the bug since we end up with a foo local rather than being global hidden.
(In reply to comment #2) > Created attachment 6424 [details] > partial fix > > This fixes the assert, but doesn't completely cure the bug since we end up with > a foo local rather than being global hidden. I posted a fix at: http://sourceware.org/ml/binutils/2012-05/msg00378.html
CVSROOT: /cvs/src Module name: src Changes by: amodra@sourceware.org 2012-05-27 13:55:45 Modified files: bfd : ChangeLog elflink.c Log message: PR ld/14170 * elflink.c (_bfd_elf_merge_symbol): When a symbol defined in a dynamic library finds a new instance with non-default visibility in a regular object, correctly handle symbols already on the undefs list and undo dynamic symbol state when the new symbol is hidden or internal. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5714&r2=1.5715 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.445&r2=1.446
CVSROOT: /cvs/src Module name: src Changes by: hjl@sourceware.org 2012-05-27 14:45:41 Modified files: ld/testsuite : ChangeLog ld/testsuite/ld-elf: elf.exp Added files: ld/testsuite/ld-elf: pr14170a.s pr14170b.s pr14170c.s Log message: Add a test for PR ld/14170 PR ld/14170 * ld-elf/elf.exp: Add a test for PR ld/14170. * ld-elf/pr14170a.s: New file. * ld-elf/pr14170b.s: Likewise. * ld-elf/pr14170b.s: Likewise. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1551&r2=1.1552 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr14170a.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr14170b.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr14170c.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/elf.exp.diff?cvsroot=src&r1=1.34&r2=1.35
CVSROOT: /cvs/src Module name: src Changes by: amodra@sourceware.org 2012-05-28 04:08:54 Modified files: ld/testsuite : ChangeLog ld/testsuite/ld-elf: pr14170a.s elf.exp Log message: PR ld/14170 * ld-elf/pr14170a.s: Put foo, bar address in .data. * ld-elf/elf.exp: Don't run pr14170 test on hppa64-hpux. Ignore tic6x warnings. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1552&r2=1.1553 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr14170a.s.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/elf.exp.diff?cvsroot=src&r1=1.35&r2=1.36
Fixed.
The master branch has been updated by Maciej W. Rozycki <macro@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8988502d75343349cee39575c0e4a0b33f7c80e0 commit 8988502d75343349cee39575c0e4a0b33f7c80e0 Author: Maciej W. Rozycki <macro@mips.com> Date: Wed Jan 31 14:47:12 2018 +0000 MIPS/LD/testsuite: Correct dynamic links with VR4100, VR4300 and VR5000 Correct LD test suite failures with VR4100, VR4300 and VR5000 bare metal MIPS/ELF targets which do not default to linking with shared libraries, which leads to link failures like: .../ld/ld-new: cannot find -lcomm-data FAIL: Common symbol override test or: .../ld/ld-new: attempted static link of dynamic object `tmpdir/pr14170.so' FAIL: PR ld/14170 removing: FAIL: Build pr22471b.so FAIL: Build pr22471 FAIL: Build pr22649-2b.so FAIL: Build pr22649-2d.so FAIL: Build pr22150 FAIL: PR ld/14170 FAIL: --gc-sections with __gxx_personality test failures. ld/ * testsuite/ld-elf/comm-data.exp: Pass `-call_shared' to links involving a shared library for `mips*vr4100*-*-elf*', `mips*vr4300*-*-elf*' and `mips*vr5000*-*-elf*' targets. * testsuite/ld-elf/provide-hidden.exp: Likewise. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-gc/gc.exp: Likewise. * testsuite/ld-mips-elf/comm-data.exp: Likewise.
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=980a2e42f7439015defdcedad89a13a72749bdb0 commit 980a2e42f7439015defdcedad89a13a72749bdb0 Author: Alan Modra <amodra@gmail.com> Date: Thu Mar 21 08:39:18 2019 +1030 lm32-linux ld testsuite fails A number of the fails are due to ld supporting the creation of shared libraries but not allowing linking against them without using an option like -Bdynamic. FAIL: Symbol export class test (final shared object) FAIL: PROVIDE_HIDDEN test 4 FAIL: PROVIDE_HIDDEN test 6 FAIL: PROVIDE_HIDDEN test 10 FAIL: PROVIDE_HIDDEN test 12 FAIL: Build pr22471b.so FAIL: Build pr22649-2b.so FAIL: Build pr22649-2d.so FAIL: PR ld/20828 dynamic symbols with section GC (plain) FAIL: PR ld/20828 dynamic symbols with section GC (version script) FAIL: PR ld/20828 dynamic symbols with section GC (versioned) FAIL: PR ld/21233 dynamic symbols with section GC (--undefined) FAIL: PR ld/21233 dynamic symbols with section GC (--require-defined) FAIL: PR ld/21233 dynamic symbols with section GC (EXTERN) FAIL: Build pr22150 FAIL: PR ld/14170 FAIL: Link using broken linker script FAIL: pr17068 link --as-needed lib in group FAIL: ld-gc/pr20022 * emulparams/elf32lm32fd.sh (DYNAMIC_LINK): Undef.
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c7c970e4c63f81479539220874a98aa74bc0e090 commit c7c970e4c63f81479539220874a98aa74bc0e090 Author: Alan Modra <amodra@gmail.com> Date: Mon Jun 22 11:50:46 2020 +0930 Correct bfin XPASSes bfin-elf and bfin-linux differ. This patch fixes these: bfin-linux-uclibc -XPASS: PR ld/14170 bfin-linux-uclibc -XPASS: pr17068 link --as-needed lib in group bfin-linux-uclibc -XPASS: -Bsymbolic-functions bfin-linux-uclibc -XPASS: pr22374 function pointer initialization * testsuite/ld-elf/shared.exp (pr14170): Clear xfail for bfin-*-linux*. (pr17068, symbolic-func.so, pr22374): Likewise.