From 0602e05a845a545a8b52386a4dec66b74a158bc7 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 27 Feb 2009 19:57:46 +0000 Subject: PR 9836 * symtab.cc (Symbol_table::add_from_object): If the visibility is hidden or internal, force the symbol to be local. * resolve.cc (Symbol::override_visibility): Define. (Symbol::override_base): Use override_visibility. (Symbol_table::resolve): Likewise. (Symbol::override_base_with_special): Likewise. (Symbol_table::override_with_special): If the visibility is hidden or internal, force the symbol to be local. * symtab.h (class Symbol): Add set_visibility and override_visibility. * testsuite/ver_test_1.sh: New file. * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_1.sh. (check_DATA): Add ver_test_1.syms. (ver_test_1.syms): New target. * testsuite/Makefile.in: Rebuild. --- gold/symtab.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'gold/symtab.cc') diff --git a/gold/symtab.cc b/gold/symtab.cc index 5408385..dcbb46e 100644 --- a/gold/symtab.cc +++ b/gold/symtab.cc @@ -648,7 +648,8 @@ Symbol_table::resolve(Sized_symbol* to, const Sized_symbol* from) this->gc_mark_dyn_syms(to); } -// Record that a symbol is forced to be local by a version script. +// Record that a symbol is forced to be local by a version script or +// by visibility. void Symbol_table::force_local(Symbol* sym) @@ -962,6 +963,15 @@ Symbol_table::add_from_object(Object* object, this->tls_commons_.push_back(ret); } + // If we're not doing a relocatable link, then any symbol with + // hidden or internal visibility is local. + if ((ret->visibility() == elfcpp::STV_HIDDEN + || ret->visibility() == elfcpp::STV_INTERNAL) + && (ret->binding() == elfcpp::STB_GLOBAL + || ret->binding() == elfcpp::STB_WEAK) + && !parameters->options().relocatable()) + this->force_local(ret); + if (def) ret->set_is_default(); return ret; @@ -1179,7 +1189,7 @@ Symbol_table::add_from_pluginobj( def, *sym, st_shndx, true, st_shndx); if (local) - this->force_local(res); + this->force_local(res); return res; } -- cgit v1.1