Bug 12893

Summary: gold reports duplicated symbols when symbols have version both in script and in source
Product: binutils Reporter: Diego Elio Pettenò <flameeyes>
Component: goldAssignee: Ian Lance Taylor <ian>
Status: RESOLVED FIXED    
Severity: normal CC: roland
Priority: P2    
Version: 2.22   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Diego Elio Pettenò 2011-06-15 19:15:34 UTC
This is arguably a bug in the developers' code itself, but at least bfd/ld seems to let it through so it could possibly be of interest to look at.

The reduced testcase is as follows:


# cat test-lib.c
void a() {
}

__asm__ (".symver a,a@TEST");

# cat test.ver 
TEST {
global:
  a;
local:
  *;
};

# gcc -Wl,--version-script=test.ver -fPIC -shared test-lib.c -o libtest.so
/usr/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../i686-pc-linux-gnu/bin/ld: error: /tmp/ccPGK7Km.o: multiple definition of 'a'
/usr/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../i686-pc-linux-gnu/bin/ld: /tmp/ccPGK7Km.o: previous definition here
collect2: ld returned 1 exit status

This is the code used by at least libdebian-installer, and it makes (some) sense if the static library also has to be usable (it would version the symbols in there as well).
Comment 1 Sourceware Commits 2011-06-17 13:31:35 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	ian@sourceware.org	2011-06-17 13:31:33

Modified files:
	gold           : ChangeLog resolve.cc 

Log message:
	PR gold/12893
	* resolve.cc (Symbol_table::resolve): Don't give an error if a
	symbol is redefined with the exact same object and value.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.758&r2=1.759
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/resolve.cc.diff?cvsroot=src&r1=1.59&r2=1.60
Comment 2 Ian Lance Taylor 2011-06-17 13:34:08 UTC
Fixed.  Thanks for reporting it.
Comment 3 Ian Lance Taylor 2011-06-17 14:08:36 UTC
*** Bug 12879 has been marked as a duplicate of this bug. ***