diff options
author | Cary Coutant <ccoutant@gmail.com> | 2018-06-20 01:24:11 -0700 |
---|---|---|
committer | Cary Coutant <ccoutant@gmail.com> | 2018-06-20 01:25:04 -0700 |
commit | ebb1332297da904a4adab0d3696a5512604f5edd (patch) | |
tree | db27440b898ad42f3200a5024e014cc40c7cb08b /gold/dynobj.cc | |
parent | 160d1b3d74593bf42155da24569f54a6e7140f65 (diff) | |
download | gdb-ebb1332297da904a4adab0d3696a5512604f5edd.zip gdb-ebb1332297da904a4adab0d3696a5512604f5edd.tar.gz gdb-ebb1332297da904a4adab0d3696a5512604f5edd.tar.bz2 |
Fix problem where gold does not create base version for executables.
gold/
PR gold/23268
* dynobj.cc (Versions::Versions): Change init for needs_base_version_.
(Versions::record_version): Add verdefs for both shared objects and
executables.
(Versions::add_def): Likewise for base version.
(Versions::add_need): Don't add base version for executables.
(Versions::version_index): Look up version for both shared objects and
executables.
* testsuite/Makefile.am (ver_test_14): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/ver_test_14.script: New version script.
* testsuite/ver_test_14.sh: New test script.
Diffstat (limited to 'gold/dynobj.cc')
-rw-r--r-- | gold/dynobj.cc | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/gold/dynobj.cc b/gold/dynobj.cc index 7012802..75e7e75 100644 --- a/gold/dynobj.cc +++ b/gold/dynobj.cc @@ -1439,7 +1439,7 @@ Versions::Versions(const Version_script_info& version_script, Stringpool* dynpool) : defs_(), needs_(), version_table_(), is_finalized_(false), version_script_(version_script), - needs_base_version_(parameters->options().shared()) + needs_base_version_(true) { if (!this->version_script_.empty()) { @@ -1536,8 +1536,7 @@ Versions::record_version(const Symbol_table* symtab, if (!sym->is_from_dynobj() && !sym->is_copied_from_dynobj()) { - if (parameters->options().shared()) - this->add_def(dynpool, sym, version, version_key); + this->add_def(dynpool, sym, version, version_key); } else { @@ -1574,18 +1573,13 @@ Versions::add_def(Stringpool* dynpool, const Symbol* sym, const char* version, // find a definition of a symbol with a version which is not // in the version script. if (parameters->options().shared()) - { - gold_error(_("symbol %s has undefined version %s"), - sym->demangled_name().c_str(), version); - if (this->needs_base_version_) - this->define_base_version(dynpool); - } - else - // We only insert a base version for shared library. - gold_assert(!this->needs_base_version_); - + gold_error(_("symbol %s has undefined version %s"), + sym->demangled_name().c_str(), version); + // When creating a regular executable, automatically define // a new version. + if (this->needs_base_version_) + this->define_base_version(dynpool); Verdef* vd = new Verdef(version, std::vector<std::string>(), false, false, false, false); this->defs_.push_back(vd); @@ -1631,7 +1625,7 @@ Versions::add_need(Stringpool* dynpool, const char* filename, const char* name, if (vn == NULL) { // Create base version definition lazily for shared library. - if (this->needs_base_version_) + if (parameters->options().shared() && this->needs_base_version_) this->define_base_version(dynpool); // We have a new filename. @@ -1715,8 +1709,6 @@ Versions::version_index(const Symbol_table* symtab, const Stringpool* dynpool, Key k; if (!sym->is_from_dynobj() && !sym->is_copied_from_dynobj()) { - if (!parameters->options().shared()) - return elfcpp::VER_NDX_GLOBAL; k = Key(version_key, 0); } else |