cat > x.s <<\EOF .section.data.rel.ro,"aw",@progbits .align 16 .type_ZZ3fooiE1t, @object .size_ZZ3fooiE1t, 16 _ZZ3fooiE1t: .quad_ZN1AIiE1aE .quad0 .weak_ZN1AIiE1aE .section.rodata._ZN1AIiE1aE,"aG",@progbits,_ZN1AIiE1aE,comdat .align 4 .type_ZN1AIiE1aE, @gnu_unique_object .size_ZN1AIiE1aE, 4 _ZN1AIiE1aE: .long16 .section.note.GNU-stack,"",@progbits EOF sed 's/foo/bar/g' x.s > y.s gas/as-new -o x.o x.s gas/as-new -o y.o y.s ld/ld-new -shared -nostdlib -o x.so x.o y.o; echo $? cp -a y.o z.o binutils/strip-new -g z.o ld/ld-new -shared -nostdlib -o x.so x.o z.o; echo $? The first link is fine, but the second complains. 0 `_ZN1AIiE1aE' referenced in section `.data.rel.ro' of z.o: defined in discarded section `.rodata._ZN1AIiE1aE[_ZN1AIiE1aE]' of z.o 1 The only difference is that one of the objects has been strip -g'ed in between.
With s/gnu_object_// it works, the difference in readelf -Wa between y.o and z.o is just the order of local symbols in .symtab. But with STB_GNU_UNIQUE, the _ZN1AIiE1aE symbol (UNIQUE) is also reordered, between other LOCAL symbols.
sounds like a tweak to sym_is_global is needed
Created attachment 4114 [details] binutils-bz10492.patch Indeed, you're right. Following patch cures it.
Please commit
Subject: Bug 10492 CVSROOT: /cvs/src Module name: src Changes by: jakub@sourceware.org 2009-08-06 13:08:24 Modified files: bfd : ChangeLog elf.c elf32-mips.c elfn32-mips.c Log message: PR binutils/10492 * elf.c (sym_is_global): Return true even for BSF_GNU_UNIQUE symbols. * elf32-mips.c (mips_elf_sym_is_global): Likewise. * elfn32-mips.c (mips_elf_sym_is_global): Likewise. Patches: http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.4722&r2=1.4723 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elf.c.diff?cvsroot=src&r1=1.487&r2=1.488 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elf32-mips.c.diff?cvsroot=src&r1=1.204&r2=1.205 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elfn32-mips.c.diff?cvsroot=src&r1=1.44&r2=1.45
Subject: Bug 10492 CVSROOT: /cvs/src Module name: src Changes by: hjl@sourceware.org 2009-08-06 16:22:36 Modified files: binutils/testsuite: ChangeLog binutils/testsuite/binutils-all: objcopy.exp Added files: binutils/testsuite/binutils-all: strip-10.d unique.s Log message: 2009-08-03 H.J. Lu <hongjiu.lu@intel.com> PR binutils/10492 * binutils-all/objcopy.exp: Run strip-10. * binutils-all/strip-10.d: New. * binutils-all/unique.s: Likewise. Patches: http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/binutils/testsuite/ChangeLog.diff?cvsroot=src&r1=1.178&r2=1.179 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/binutils/testsuite/binutils-all/strip-10.d.diff?cvsroot=src&r1=NONE&r2=1.1 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/binutils/testsuite/binutils-all/unique.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/binutils/testsuite/binutils-all/objcopy.exp.diff?cvsroot=src&r1=1.60&r2=1.61