// dynobj.cc -- dynamic object support for gold
-// Copyright (C) 2006-2017 Free Software Foundation, Inc.
+// Copyright (C) 2006-2020 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
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())
{
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
{
// 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);
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.
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
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())
+ if ((*p)->version() != NULL
+ && (*p)->is_defined()
+ && !(*p)->is_default()
+ && !(*p)->from_dyn())
version_index |= elfcpp::VERSYM_HIDDEN;
elfcpp::Swap<16, big_endian>::writeval(pbuf + (*p)->dynsym_index() * 2,
version_index);