aboutsummaryrefslogtreecommitdiff
path: root/gold/symtab.cc
diff options
context:
space:
mode:
authorSriraman Tallam <tmsriram@google.com>2011-10-31 21:36:54 +0000
committerSriraman Tallam <tmsriram@google.com>2011-10-31 21:36:54 +0000
commit7257cc92acfa8a53a200d9efa69913d3292c480f (patch)
tree59ac76e318310c04d83ca98b1f0a9a69b4994e80 /gold/symtab.cc
parentb9fd179153353a88a34dd97a03ee698376212d29 (diff)
downloadgdb-7257cc92acfa8a53a200d9efa69913d3292c480f.zip
gdb-7257cc92acfa8a53a200d9efa69913d3292c480f.tar.gz
gdb-7257cc92acfa8a53a200d9efa69913d3292c480f.tar.bz2
2011-10-31 Sriraman Tallam <tmsriram@google.com>
* symtab.h (Symbol_table::gc_mark_symbol_for_shlib): Rename to gc_mark_symbol. * symtab.cc (Symbol_table::gc_mark_symbol_for_shlib): Rename to gc_mark_symbol. Change to just keep the section associated with symbol. (Symbol_table::add_from_relobj): Mark symbols as not garbage when they are externally visible and --export-dynamic is turned on. (Symbol_table::gc_mark_dyn_syms): Call gc_mark_symbol.
Diffstat (limited to 'gold/symtab.cc')
-rw-r--r--gold/symtab.cc46
1 files changed, 19 insertions, 27 deletions
diff --git a/gold/symtab.cc b/gold/symtab.cc
index a90fee4..3b76adb 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -602,20 +602,16 @@ Symbol_table::gc_mark_undef_symbols(Layout* layout)
}
void
-Symbol_table::gc_mark_symbol_for_shlib(Symbol* sym)
+Symbol_table::gc_mark_symbol(Symbol* sym)
{
- if (!sym->is_from_dynobj()
- && sym->is_externally_visible())
+ // Add the object and section to the work list.
+ Relobj* obj = static_cast<Relobj*>(sym->object());
+ bool is_ordinary;
+ unsigned int shndx = sym->shndx(&is_ordinary);
+ if (is_ordinary && shndx != elfcpp::SHN_UNDEF)
{
- //Add the object and section to the work list.
- Relobj* obj = static_cast<Relobj*>(sym->object());
- bool is_ordinary;
- unsigned int shndx = sym->shndx(&is_ordinary);
- if (is_ordinary && shndx != elfcpp::SHN_UNDEF)
- {
- gold_assert(this->gc_!= NULL);
- this->gc_->worklist().push(Section_id(obj, shndx));
- }
+ gold_assert(this->gc_!= NULL);
+ this->gc_->worklist().push(Section_id(obj, shndx));
}
}
@@ -626,16 +622,7 @@ Symbol_table::gc_mark_dyn_syms(Symbol* sym)
{
if (sym->in_dyn() && sym->source() == Symbol::FROM_OBJECT
&& !sym->object()->is_dynamic())
- {
- Relobj* obj = static_cast<Relobj*>(sym->object());
- bool is_ordinary;
- unsigned int shndx = sym->shndx(&is_ordinary);
- if (is_ordinary && shndx != elfcpp::SHN_UNDEF)
- {
- gold_assert(this->gc_ != NULL);
- this->gc_->worklist().push(Section_id(obj, shndx));
- }
- }
+ this->gc_mark_symbol(sym);
}
// Make TO a symbol which forwards to FROM.
@@ -1251,11 +1238,16 @@ Symbol_table::add_from_relobj(
if (is_forced_local)
this->force_local(res);
- // If building a shared library using garbage collection, do not
- // treat externally visible symbols as garbage.
- if (parameters->options().gc_sections()
- && parameters->options().shared())
- this->gc_mark_symbol_for_shlib(res);
+ // Do not treat this symbol as garbage if this symbol will be
+ // exported to the dynamic symbol table. This is true when
+ // building a shared library or using --export-dynamic and
+ // the symbol is externally visible.
+ if (parameters->options().gc_sections()
+ && res->is_externally_visible()
+ && !res->is_from_dynobj()
+ && (parameters->options().shared()
+ || parameters->options().export_dynamic()))
+ this->gc_mark_symbol(res);
if (is_defined_in_discarded_section)
res->set_is_defined_in_discarded_section();