Linker garbage collection should not collect unreferenced symbols if they are externally visible and export-dynamic is on
Sriraman Tallam
tmsriram@google.com
Mon Oct 31 21:37:00 GMT 2011
Thanks, made those changes and committed the patch.
-Sri.
On Mon, Oct 31, 2011 at 2:24 PM, Ian Lance Taylor <iant@google.com> wrote:
> Sriraman Tallam <tmsriram@google.com> writes:
>
>> * 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.
>
>
>> 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.
>
> Space after "//".
>
>
>> @@ -626,16 +622,7 @@ Symbol_table::gc_mark_dyn_syms(Symbol* s
>> {
>> 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));
>> - }
>> - }
>> + gc_mark_symbol(sym);
>> }
>
> Write this->gc_mark_symbol(sym);
>
>
> This is OK with those changes.
>
> Thanks.
>
> Ian
>
More information about the Binutils
mailing list