Bug 9836 - wrong visibility in shared objects
Summary: wrong visibility in shared objects
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-11 17:12 UTC by Duncan Sands
Modified: 2014-05-28 19:44 UTC (History)
3 users (show)

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 Duncan Sands 2009-02-11 17:12:33 UTC
The file null.cpp is empty.  Using GNU ld (GNU Binutils for Ubuntu) 2.19.1:

$ g++ -shared null.cpp -o null.so && nm null.so | grep __dso_handle
0000000000201008 d __dso_handle

Note that __dso_handle is an internal symbol.

Using GNU gold (GNU Binutils 2.19.51.20090211) 1.9:

$ g++ -shared null.cpp -o null.so && nm null.so | grep __dso_handle
0000000000002000 D __dso_handle

Note that __dso_handle is an external symbol.

This testcase is reduced from the LLVM compiler which fails to
build when linked with gold and configured with --enable-pic,
because it thinks there are circular library dependencies.  The
reason for that is that in the shared libraries a bunch of symbols
are external when linked with gold but internal with the usual ld.
These symbols confuse the script that checks for circular dependencies.
Comment 1 Duncan Sands 2009-02-16 10:31:12 UTC
Please note that __dso_handle is not the only symbol being
wrongly marked external.  Analysis of the LLVM libraries
shows a bunch of symbols (some LLVM specific, some compiler
specific, eg: __stack_chk_fail_local) for which this happens.
Comment 2 Sourceware Commits 2009-02-27 19:57:58 UTC
Subject: Bug 9836

CVSROOT:	/cvs/src
Module name:	src
Changes by:	ian@sourceware.org	2009-02-27 19:57:46

Modified files:
	gold           : ChangeLog resolve.cc symtab.cc symtab.h 
	gold/testsuite : Makefile.am Makefile.in 
Added files:
	gold/testsuite : ver_test_1.sh 

Log message:
	PR 9836
	* symtab.cc (Symbol_table::add_from_object): If the visibility is
	hidden or internal, force the symbol to be local.
	* resolve.cc (Symbol::override_visibility): Define.
	(Symbol::override_base): Use override_visibility.
	(Symbol_table::resolve): Likewise.
	(Symbol::override_base_with_special): Likewise.
	(Symbol_table::override_with_special): If the visibility is hidden
	or internal, force the symbol to be local.
	* symtab.h (class Symbol): Add set_visibility and
	override_visibility.
	* testsuite/ver_test_1.sh: New file.
	* testsuite/Makefile.am (check_SCRIPTS): Add ver_test_1.sh.
	(check_DATA): Add ver_test_1.syms.
	(ver_test_1.syms): New target.
	* testsuite/Makefile.in: Rebuild.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.181&r2=1.182
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/resolve.cc.diff?cvsroot=src&r1=1.38&r2=1.39
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/symtab.cc.diff?cvsroot=src&r1=1.114&r2=1.115
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/symtab.h.diff?cvsroot=src&r1=1.84&r2=1.85
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/testsuite/ver_test_1.sh.diff?cvsroot=src&r1=NONE&r2=1.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/testsuite/Makefile.am.diff?cvsroot=src&r1=1.84&r2=1.85
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/testsuite/Makefile.in.diff?cvsroot=src&r1=1.89&r2=1.90

Comment 3 Ian Lance Taylor 2009-02-27 19:59:41 UTC
Thanks for reporting the bug.

Now fixed.
Comment 4 Duncan Sands 2009-02-27 22:37:57 UTC
Confirmed - LLVM now builds fine when using gold.  Thanks for fixing it!
Comment 5 Jackie Rosen 2014-02-16 17:45:47 UTC Comment hidden (spam)