Bug 10492 - strip -g breaks objects with STB_GNU_UNIQUE
Summary: strip -g breaks objects with STB_GNU_UNIQUE
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.20
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-06 12:24 UTC by Jakub Jelinek
Modified: 2009-08-06 12:51 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-linux
Build:
Last reconfirmed:


Attachments
binutils-bz10492.patch (401 bytes, patch)
2009-08-06 12:45 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2009-08-06 12:24:55 UTC
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.
Comment 1 Jakub Jelinek 2009-08-06 12:29:45 UTC
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.
Comment 2 Alan Modra 2009-08-06 12:36:58 UTC
sounds like a tweak to sym_is_global is needed
Comment 3 Jakub Jelinek 2009-08-06 12:45:11 UTC
Created attachment 4114 [details]
binutils-bz10492.patch

Indeed, you're right.  Following patch cures it.
Comment 4 Alan Modra 2009-08-06 12:51:22 UTC
Please commit
Comment 5 cvs-commit@gcc.gnu.org 2009-08-06 13:08:39 UTC
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

Comment 6 cvs-commit@gcc.gnu.org 2009-08-06 16:22:49 UTC
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