PATCH COMMITTED: Fix weak aliasing bug
Ian Lance Taylor
Wed Apr 9 22:50:00 GMT 2008
I found a tricky weak aliasing bug in gold. If gold sees the
1) Shared library S1 defines a weak symbol W.
2) Shared library S2 defines a strong symbol S which happens to have
the same section index and value as W, although it is a different
3) Regular object O, seen after S1 and S2, also defines symbol the
weak symbol W.
Then it will bring W into the main executable, as it should, but it
will also incorrectly bring S into the main executable as an alias for
W, which is wrong.
This patch fixes the bug, along with a test case. The test case is
careful to ensure that W and S have the same section and index by
ensuring that the dynamic symbol table and dynamic string table in S1
and S2 are exactly the same length. The test case also includes
unrelated tests for the correct behaviour of weak aliases. These were
already working, but it obviously doesn't hurt to test them.
2008-04-09 Ian Lance Taylor <email@example.com>
* symtab.cc (Symbol_table::add_from_dynobj): Only look for weak
aliases for symbols defined in the same object.
* testsuite/Makefile.am (check_PROGRAMS): Add weak_alias_test.
(weak_alias_test_SOURCES): New variable.
(weak_alias_test_DEPENDENCIES): New variable.
(weak_alias_test_LDFLAGS): New variable.
(weak_alias_test_LDADD): New variable.
(weak_alias_test_1_pic.o, weak_alias_test_1.so): New targets.
(weak_alias_test_2_pic.o, weak_alias_test_2.so): New targets.
(weak_alias_test_3.o): New target.
(weak_alias_test_4_pic.o, weak_alias_test_4.so): New targets.
* testsuite/weak_alias_test_main.cc: New file.
* testsuite/weak_alias_test_1.cc: New file.
* testsuite/weak_alias_test_2.cc: New file.
* testsuite/weak_alias_test_3.cc: New file.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 12346 bytes
Desc: Fix weak aliasing bug
More information about the Binutils