int i; static int * g(void) { return &i; } struct S { static int * f(void) { static int *p = g(); return p; } }; int * wrap2_f (void) { return S::f(); } g++ -O2 -fpic -shared -o lib.so lib.cc -Wl,-Bsymbolic (assuming gcc has been configured to use STB_GNU_UNIQUE). There are no relocations against _ZZN1S1fEvE1p (STB_GNU_UNIQUE) symbol defined in this library. While for non-STB_GNU_UNIQUE symbols that's desirable, the symbol will always resolve to the containing library, for STB_GNU_UNIQUE it causes the symbol to be no longer unique in the whole program.
Created attachment 4682 [details] A patch Please try this patch.
Created attachment 4683 [details] An updated patch We don't need to check unique_global for ifunc symbols.
A patch with a testcase is posted at http://sourceware.org/ml/binutils/2010-03/msg00395.html
Subject: Bug 11434 CVSROOT: /cvs/src Module name: src Changes by: hjl@sourceware.org 2010-04-07 02:41:35 Modified files: bfd : ChangeLog elf-bfd.h ld : ChangeLog ld/testsuite/ld-x86-64: x86-64.exp Added files: ld/testsuite/ld-x86-64: unique1.d unique1.s Log message: Don't bind unique symbol locally. bfd/ 2010-04-06 H.J. Lu <hongjiu.lu@intel.com> PR ld/11434 * elf-bfd.h (SYMBOLIC_BIND): Don't bind unique symbol locally. ld/testsuite/ 2010-04-06 H.J. Lu <hongjiu.lu@intel.com> PR ld/11434 * ld/testsuite/ld-x86-64/unique1.d: New. * ld/testsuite/ld-x86-64/unique1.s: Likewise. * ld-x86-64/x86-64.exp: Run unique1. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.4980&r2=1.4981 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-bfd.h.diff?cvsroot=src&r1=1.301&r2=1.302 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2130&r2=1.2131 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/unique1.d.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/unique1.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/x86-64.exp.diff?cvsroot=src&r1=1.15&r2=1.16
Fixed.