Bug 15146 - Reference from dummy plugin symbol isn't removed
Summary: Reference from dummy plugin symbol isn't removed
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-13 18:01 UTC by H.J. Lu
Modified: 2013-04-03 11:44 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2013-02-13 18:01:24 UTC
[hjl@gnu-6 pr15126]$ cat foo.c
int main() { }
[hjl@gnu-6 pr15126]$ cat bar.c
extern int xxx;

int
bar ()
{
  return xxx;
}
[hjl@gnu-6 pr15126]$ cat xxx.c
int xxx __attribute__ ((weak)) = 3;
[hjl@gnu-6 pr15126]$ cat yyy.c
[hjl@gnu-6 pr15126]$ make
gcc -flto   -c -o bar.o bar.c
gcc -flto   -c -o foo.o foo.c
gcc -shared -fPIC -o libxxx.so xxx.c
gcc -shared -fPIC -o libyyy.so yyy.c libxxx.so
gcc -flto -O2  -o x bar.o foo.o libyyy.so -Wl,-rpath-link,.
/usr/local/bin/ld: bar.o (symbol from plugin): undefined reference to symbol 'xxx'
/usr/local/bin/ld: note: 'xxx' is defined in DSO ./libxxx.so so try adding it to the linker command line
./libxxx.so: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [x] Error 1
Comment 1 cvs-commit@gcc.gnu.org 2013-02-16 17:54:42 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2013-02-16 17:54:37

Modified files:
	ld             : ChangeLog plugin.c 
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-plugin: lto.exp 
	bfd            : ChangeLog elflink.c 
Added files:
	ld/testsuite/ld-plugin: pr15146.d pr15146a.c pr15146b.c 
	                        pr15146d.c 

Log message:
	Don't add DT_NEEDED for references from the dummy bfd
	
	bfd/
	
	PR ld/15146
	* elflink.c (elf_link_add_object_symbols): Don't add DT_NEEDED
	for references from the dummy bfd.
	
	ld/
	
	PR ld/15146
	* plugin.c (plugin_notice): Replace the undefined dummy bfd with
	the real one.
	
	ld/testsuite/
	
	PR ld/15146
	* ld-plugin/pr15146.d: New file.
	* ld-plugin/pr15146a.c: Likewise.
	* ld-plugin/pr15146b.c: Likewise.
	* ld-plugin/pr15146c.c: Likewise.
	* ld-plugin/pr15146d.c: Likewise.
	
	* ld-plugin/lto.exp: Add tests for PR ld/15146.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2556&r2=1.2557
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.c.diff?cvsroot=src&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1686&r2=1.1687
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/pr15146.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/pr15146a.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/pr15146b.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/pr15146d.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/lto.exp.diff?cvsroot=src&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5969&r2=1.5970
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.468&r2=1.469
Comment 2 H.J. Lu 2013-02-16 18:25:31 UTC
Fixed.
Comment 3 cvs-commit@gcc.gnu.org 2013-02-18 09:13:15 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2013-02-18 09:13:11

Modified files:
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-plugin: lto.exp 

Log message:
	* ld-plugin/lto.exp (Build pr15146b.so) Add -Wl,--no-as-needed.
	(PR ld/15146 (1), (2)): Likewise.
	(LTO 7): Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1687&r2=1.1688
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/lto.exp.diff?cvsroot=src&r1=1.4&r2=1.5
Comment 4 cvs-commit@gcc.gnu.org 2013-02-19 03:59:12 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	sandra@sourceware.org	2013-02-19 03:59:09

Modified files:
	ld             : ChangeLog plugin.c 

Log message:
	2013-02-19  Sandra Loosemore  <sandra@codesourcery.com>
	
	PR ld/15146
	
	ld/
	* plugin.c (plugin_notice): Add null check before dereferencing
	pointer.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2558&r2=1.2559
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.c.diff?cvsroot=src&r1=1.49&r2=1.50
Comment 5 cvs-commit@gcc.gnu.org 2013-04-03 11:44:43 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2013-04-03 11:44:41

Modified files:
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-plugin: lto.exp pr12942a.cc 

Log message:
	PR ld/15227
	* ld-plugin/lto.exp (PR ld/12942 (3)): Remove file name and
	line number from regexp.
	(PR ld/15146 (2)): Similarly.
	* ld-plugin/pr12942a.cc (main): Use __builtin_abort.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1704&r2=1.1705
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/lto.exp.diff?cvsroot=src&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/pr12942a.cc.diff?cvsroot=src&r1=1.1&r2=1.2