aboutsummaryrefslogtreecommitdiff
path: root/gold/dynobj.cc
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@gmail.com>2015-07-27 15:09:08 -0700
committerCary Coutant <ccoutant@gmail.com>2015-08-18 19:24:41 -0700
commitb45e00b3ed40589af75b8a36a67905ae265a20f8 (patch)
treeb9b7e0b810d2cc3327cb743f14f3241e173b0d5c /gold/dynobj.cc
parente49433d22dae92a56ae15a8b5742cbf1f31d5fd1 (diff)
downloadgdb-b45e00b3ed40589af75b8a36a67905ae265a20f8.zip
gdb-b45e00b3ed40589af75b8a36a67905ae265a20f8.tar.gz
gdb-b45e00b3ed40589af75b8a36a67905ae265a20f8.tar.bz2
Fix symbol versioning problems in PR 18703.
If a symbol is defined with ".symver foo,foo@VER", the assembler creates two symbols in the object: one unversioned, and one with the (non-default) version "VER". If foo is listed in a version script, gold would then make the first of those symbols the default version, and would ignore the second symbol as a duplicate, without making it a non-default version. While this is arguably reasonable behavior, it doesn't match Gnu ld behavior, so this patch fixes that by allowing the second definition to override the first by resetting the "default version" indication. Several test cases from the Gnu ld testsuite also exposed another related problem, where a symbol defined with ".symver foo,foo@", placed into a shared library, is not handled properly by gold. This patch also fixes that case, binding the symbol to the base version. gold/ PR gold/18703 * dynobj.cc (Versions::record_version): Handle symbol defined with base version. (Versions::symbol_section_contents): Likewise. * symtab.h (Symbol::set_is_not_default): New class method. (Symbol_table::resolve): Add is_default_version parameter. (Symbol_table::should_override): Likewise. * resolve.cc (Symbol_table::resolve): Add is_default_version parameter, and pass to should_override. Adjust all callers and explicit instantiations. (Symbol_table::should_override): Add is_default_value parameter; allow default version in a dynamic object to override existing definition from same object. * symtab.cc (Symbol_table::add_from_object): Handle case where same symbol is defined as unversioned and non-default version in the same object. * testsuite/Makefile.am (ver_test_13): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/ver_test_4.cc: Add test for symbol with base version. * testsuite/ver_test_4.sh: Likewise. * testsuite/ver_test_13.c: New source file. * testsuite/ver_test_13.script: New version script. * testsuite/ver_test_13.sh: New test case.
Diffstat (limited to 'gold/dynobj.cc')
-rw-r--r--gold/dynobj.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/gold/dynobj.cc b/gold/dynobj.cc
index 13e3f61..9ab6bf8 100644
--- a/gold/dynobj.cc
+++ b/gold/dynobj.cc
@@ -1499,6 +1499,10 @@ Versions::record_version(const Symbol_table* symtab,
gold_assert(!this->is_finalized_);
gold_assert(sym->version() != NULL);
+ // A symbol defined as "sym@" is bound to an unspecified base version.
+ if (sym->version()[0] == '\0')
+ return;
+
Stringpool::Key version_key;
const char* version = dynpool->add(sym->version(), false, &version_key);
@@ -1731,15 +1735,17 @@ Versions::symbol_section_contents(const Symbol_table* symtab,
{
unsigned int version_index;
const char* version = (*p)->version();
- if (version != NULL)
- version_index = this->version_index(symtab, dynpool, *p);
- else
+ if (version == NULL)
{
if ((*p)->is_defined() && !(*p)->is_from_dynobj())
version_index = elfcpp::VER_NDX_GLOBAL;
else
version_index = elfcpp::VER_NDX_LOCAL;
}
+ else if (version[0] == '\0')
+ version_index = elfcpp::VER_NDX_GLOBAL;
+ else
+ version_index = this->version_index(symtab, dynpool, *p);
// If the symbol was defined as foo@V1 instead of foo@@V1, add
// the hidden bit.
if ((*p)->version() != NULL && !(*p)->is_default())