Bug 6811

Summary: system library path heuristics fail in some cases
Product: binutils Reporter: Kris Van Hees <kris.van.hees>
Component: goldAssignee: Ian Lance Taylor <ian>
Status: RESOLVED FIXED    
Severity: normal CC: bug-binutils
Priority: P2    
Version: 2.19   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Kris Van Hees 2008-07-31 19:50:49 UTC
The current heuristic in gold to determine whether a library is located in the
system library path (to surpress errors about undefined symbols) fails in cases
where e.g. a stub library exists for the C library.  The stub library would also
be named libc.so, but it would be in a location other than the system library
path.  Still, gold will register that location as the system library path, and
the end result is that suddenly errors end up being reported for undefined
symbols related to libraries in the "real" system library path because they are
not recognized as system libraries anymore.

In all, I do not believe that a heuristic will ever truly work for this
situation because it depends on assumptions that are not guaranteed for all
cases.  A hardcoded (or at-gold-compile-time determined) system library path is
not necessarily guaranteed either, but it is likely to be more robust than the
current heuristic.
Comment 1 Sourceware Commits 2009-02-28 04:40:13 UTC
Subject: Bug 6811

CVSROOT:	/cvs/src
Module name:	src
Changes by:	ian@sourceware.org	2009-02-28 04:39:57

Modified files:
	gold           : ChangeLog fileread.cc fileread.h layout.cc 
	                 object.cc object.h options.cc options.h 
	                 symtab.cc symtab.h 

Log message:
	PR 6811
	* options.h (class Search_directory): Add is_system_directory.
	(class General_options): Declare is_in_system_directory.
	* options.cc (get_relative_sysroot): Make static.
	(get_default_sysroot): Make static.
	(General_optoins::is_in_system_directory): New function.
	* fileread.cc (Input_file::is_in_system_directory): New function.
	* fileread.h (class Input_file): Declare is_in_system_directory.
	* object.h (class Object): Add is_in_system_directory.
	(class Input_objects): Remove system_library_directory_ field.
	* object.cc (Input_objects::add_object): Don't set
	system_library_directory_.
	(input_objects::found_in_system_library_directory): Remove.
	* symtab.cc (Symbol_table::write_globals): Remove input_objects
	parameter.  Change all callers.
	(Symbol_table::sized_write_globals): Likewise.
	(Symbol_table::warn_about_undefined_dynobj_symbol): Likewise.
	Call Object::is_in_system_directory.
	* symtab.h (class Symbol_table): Update declarations.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.184&r2=1.185
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/fileread.cc.diff?cvsroot=src&r1=1.47&r2=1.48
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/fileread.h.diff?cvsroot=src&r1=1.32&r2=1.33
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/layout.cc.diff?cvsroot=src&r1=1.117&r2=1.118
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/object.cc.diff?cvsroot=src&r1=1.85&r2=1.86
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/object.h.diff?cvsroot=src&r1=1.69&r2=1.70
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/options.cc.diff?cvsroot=src&r1=1.82&r2=1.83
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/options.h.diff?cvsroot=src&r1=1.94&r2=1.95
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/symtab.cc.diff?cvsroot=src&r1=1.115&r2=1.116
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/symtab.h.diff?cvsroot=src&r1=1.85&r2=1.86

Comment 2 Ian Lance Taylor 2009-02-28 04:42:58 UTC
I committed a patch which improves the heuristic.  Let me know if you see any
problems with this approach.