X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gold%2Fsymtab.cc;h=205444b5ea0e8404ff3771725b723a05ac6d6eed;hb=50d036364fb2a71b3ac9a0b0cdbe58296832a1b2;hp=c43d127507e6dc7b7f96ef37970e444e4ae617b0;hpb=cea6ffbd06a6ebb5c21cb51e7775b8ebb5e34f38;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/symtab.cc b/gold/symtab.cc index c43d127507..205444b5ea 100644 --- a/gold/symtab.cc +++ b/gold/symtab.cc @@ -1,6 +1,6 @@ // symtab.cc -- the gold symbol table -// Copyright (C) 2006-2018 Free Software Foundation, Inc. +// Copyright (C) 2006-2020 Free Software Foundation, Inc. // Written by Ian Lance Taylor . // This file is part of gold. @@ -565,8 +565,8 @@ Symbol::set_undefined() Symbol_table::Symbol_table(unsigned int count, const Version_script_info& version_script) - : saw_undefined_(0), offset_(0), table_(count), namepool_(), - forwarders_(), commons_(), tls_commons_(), small_commons_(), + : saw_undefined_(0), offset_(0), has_gnu_output_(false), table_(count), + namepool_(), forwarders_(), commons_(), tls_commons_(), small_commons_(), large_commons_(), forced_locals_(), warnings_(), version_script_(version_script), gc_(NULL), icf_(NULL), target_symbols_() @@ -1898,10 +1898,13 @@ Symbol_table::define_special_symbol(const char** pname, const char** pversion, add_to_table = true; add_loc = ins.first; - if (is_default_version && !insdefault.second) + if (is_default_version + && !insdefault.second + && insdefault.first->second->version() == NULL) { // We are adding NAME/VERSION, and it is the default - // version. We already have an entry for NAME/NULL. + // version. We already have an entry for NAME/NULL + // that does not already have a version. oldsym = insdefault.first->second; *resolve_oldsym = true; } @@ -2562,6 +2565,8 @@ Symbol_table::set_dynsym_indexes(unsigned int index, ++index; ++forced_local_count; dynpool->add(sym->name(), false, NULL); + if (sym->type() == elfcpp::STT_GNU_IFUNC) + this->set_has_gnu_output(); } } *pforced_local_count = forced_local_count; @@ -2580,7 +2585,13 @@ Symbol_table::set_dynsym_indexes(unsigned int index, if (!sym->should_add_dynsym_entry(this)) sym->set_dynsym_index(-1U); else - dyn_symbols.push_back(sym); + { + dyn_symbols.push_back(sym); + if (sym->type() == elfcpp::STT_GNU_IFUNC + || (sym->binding() == elfcpp::STB_GNU_UNIQUE + && parameters->options().gnu_unique())) + this->set_has_gnu_output(); + } } return parameters->target().set_dynsym_indexes(&dyn_symbols, index, syms, @@ -2608,6 +2619,10 @@ Symbol_table::set_dynsym_indexes(unsigned int index, ++index; syms->push_back(sym); dynpool->add(sym->name(), false, NULL); + if (sym->type() == elfcpp::STT_GNU_IFUNC + || (sym->binding() == elfcpp::STB_GNU_UNIQUE + && parameters->options().gnu_unique())) + this->set_has_gnu_output(); // Record any version information, except those from // as-needed libraries not seen to be needed. Note that the @@ -2620,11 +2635,12 @@ Symbol_table::set_dynsym_indexes(unsigned int index, versions->record_version(this, dynpool, sym); else { - gold_warning(_("discarding version information for " - "%s@%s, defined in unused shared library %s " - "(linked with --as-needed)"), - sym->name(), sym->version(), - sym->object()->name().c_str()); + if (parameters->options().warn_drop_version()) + gold_warning(_("discarding version information for " + "%s@%s, defined in unused shared library %s " + "(linked with --as-needed)"), + sym->name(), sym->version(), + sym->object()->name().c_str()); sym->clear_version(); } } @@ -2692,6 +2708,13 @@ Symbol_table::finalize(off_t off, off_t dynoff, size_t dyn_global_index, else gold_unreachable(); + if (this->has_gnu_output_) + { + Target* target = const_cast(¶meters->target()); + if (target->osabi() == elfcpp::ELFOSABI_NONE) + target->set_osabi(elfcpp::ELFOSABI_GNU); + } + // Now that we have the final symbol table, we can reliably note // which symbols should get warnings. this->warnings_.note_warnings(this); @@ -2743,6 +2766,8 @@ Symbol_table::sized_finalize(off_t off, Stringpool* pool, { this->add_to_final_symtab(sym, pool, &index, &off); ++*plocal_symcount; + if (sym->type() == elfcpp::STT_GNU_IFUNC) + this->set_has_gnu_output(); } } @@ -2753,7 +2778,13 @@ Symbol_table::sized_finalize(off_t off, Stringpool* pool, { Symbol* sym = p->second; if (this->sized_finalize_symbol(sym)) - this->add_to_final_symtab(sym, pool, &index, &off); + { + this->add_to_final_symtab(sym, pool, &index, &off); + if (sym->type() == elfcpp::STT_GNU_IFUNC + || (sym->binding() == elfcpp::STB_GNU_UNIQUE + && parameters->options().gnu_unique())) + this->set_has_gnu_output(); + } } // Now do target-specific symbols.