Created attachment 6848 [details] unique_shared_ref.s Instructions (as tested on Fedora 18 x86_64): $ as unique_shared_ref.s -o unique_shared_ref.o $ as unique_shared.s -o unique_shared.o $ ld -shared -o unique_shared_ref.so unique_shared_ref.o $ ld -o unique_shared_ref unique_shared_ref.o unique_shared.so $ readelf -s unique_shared_ref | grep UNIQ 1: 0000000000000000 0 OBJECT UNIQUE DEFAULT UND b 11: 0000000000000000 0 OBJECT UNIQUE DEFAULT UND b $ readelf -h unique_shared_ref | grep ABI OS/ABI: UNIX - System V ABI Version: 0 Either the ABI should be set to GNU, or GNU_UNIQUE shouldn't be used for the symbol reference. See this mailing list thread: <http://sourceware.org/ml/binutils/2013-01/msg00362.html>
Created attachment 6849 [details] unique_shared.s
Please try this diff --git a/bfd/elflink.c b/bfd/elflink.c index d336730..789ae12 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -8868,7 +8868,7 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data) /* Turn off visibility on local symbol. */ sym.st_other &= ~ELF_ST_VISIBILITY (-1); } - else if (h->unique_global) + else if (h->unique_global && h->def_regular) sym.st_info = ELF_ST_INFO (STB_GNU_UNIQUE, h->type); else if (h->root.type == bfd_link_hash_undefweak || h->root.type == bfd_link_hash_defweak)
(In reply to comment #2) > Please try this The reference is now GLOBAL instead of LOOS+0/GNU_UNIQUE. But I don't know if this breaks anything else.
(In reply to comment #3) > (In reply to comment #2) > > Please try this > > The reference is now GLOBAL instead of LOOS+0/GNU_UNIQUE. But I don't know if > this breaks anything else. It shouldn't and it is consistent with gold.
CVSROOT: /cvs/src Module name: src Changes by: hjl@sourceware.org 2013-02-08 01:33:01 Modified files: ld/testsuite : ChangeLog ld/testsuite/ld-unique: unique_empty.s bfd : ChangeLog elflink.c Log message: Set STB_GNU_UNIQUE only if symbol is defined in regular object bfd/ PR ld/15107 * elflink.c (elf_link_output_extsym): Set STB_GNU_UNIQUE only if symbol is defined in regular object. ld/testsuite/ PR ld/15107 * ld-unique/unique_empty.s: Add reference to "b". Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1679&r2=1.1680 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-unique/unique_empty.s.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5935&r2=1.5936 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.464&r2=1.465
Fixed.