gold patch committed: Improve special symbol version handling

Ian Lance Taylor
Tue Mar 17 07:15:00 GMT 2009

I forgot to append the patch.


Ian Lance Taylor <> writes:

> gold uses separate routines to resolve normal symbols and symbols which
> are defined by the linker itself.  The latter routine didn't do the full
> version handling of the former.  This caused it to do the wrong thing in
> the case where a special symbol was seen in an object file with no
> version, and was then later defined by the linker with a version.  This
> is not a normal case, but it will happen when using a linker script
> which uses "global: *;".  I committed this patch to improve the
> situation.  In the long run the distinction between the two types of
> symbols may be a mistake, and it may be appropriate to share more of the
> resolution routines.  This would have to be done without slowing down
> the normal case, of course.  I took a step toward that by having both
> version call a new define_default_version function.
> This fixes a problem on SPARC GNU/Linux, in which the
> _GLOBAL_OFFSET_TABLE_ symbol can be referenced by crti.o before any .got
> section is seen.  This showed up in ver_test_8 in the gold testsuite.
> Ian
> 2009-03-17  Ian Lance Taylor  <>
> 	* (Symbol_table::define_default_version): New function,
> 	broken out of add_from_object.
> 	(Symbol_table::add_from_object): Call define_default_version.
> 	(Symbol_table::define_special_symbol): Add resolve_oldsym
> 	parameter.  Change all callers.  If the version for a symbol comes
> 	from a version script, resolve it with the symbol with the same
> 	name with no version.  Also add the symbol without a version if
> 	appropriate.
> 	(do_define_in_output_data): If resolving with oldsym, don't delete
> 	sym.
> 	(do_define_in_output_segment): Likewise.
> 	(do_define_as_constant): Likewise.
> 	* symtab.h (class Symbol_table): Update declarations.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-patch
Size: 17400 bytes
Desc: Fix special symbol version handling
URL: <>

More information about the Binutils mailing list