gold patch committed: Fix complex common case

Ian Lance Taylor iant@google.com
Thu Dec 31 05:11:00 GMT 2009


gold gets confused in the following situation:

* It sees a common symbol S with no version.
* It sees a reference to a symbol S with a version V.
* It sees a non-common definition of the symbol S with version V,
  where V is the default version.

In that scenario, it winds up adding the symbol twice to the list of
common symbols to be allocated.  This happens due to the symbol
forwarding which is installed when we see S/NULL, then a reference to
S/V, then a default definition of S/V.

It's hard to avoid the situation, so I just worked around it by not
crashing if we try to allocate the same common symbol twice.

Committed to mainline, with a test case.

Ian


2009-12-30  Ian Lance Taylor  <iant@google.com>

	PR 10979
	* common.cc (Sort_commons::operator()): Stabilize sort when both
	entries are NULL.
	(Symbol_table::do_allocate_commons_list): When allocating common
	symbols, skip a symbol which is no longer common.
	* symtab.h (Symbol::is_common): Test whether the symbol comes from
	an object before checking its type.
	* testsuite/common_test_2.c: New file.
	* testsuite/common_test_3.c: New file.
	* testsuite/Makefile.am (check_PROGRAMS): Add common_test_2.
	(common_test_2_SOURCES, common_test_2_DEPENDENCIES): Define.
	(common_test_2_LDFLAGS, common_test_2_LDADD): Define.
	(common_test_2_pic.o, common_test_2.so): New targets.
	(common_test_3_pic.o, common_test_3.so): New targets.
	* testsuite/Makefile.in: Rebuild.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-diff
Size: 6240 bytes
Desc: common
URL: <https://sourceware.org/pipermail/binutils/attachments/20091231/d1233966/attachment.bin>


More information about the Binutils mailing list