This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Linker garbage collection should not collect unreferenced symbols if they are externally visible and export-dynamic is on
- From: Ian Lance Taylor <iant at google dot com>
- To: Sriraman Tallam <tmsriram at google dot com>
- Cc: binutils <binutils at sourceware dot org>, Cary Coutant <ccoutant at google dot com>, Paul Pluzhnikov <ppluzhnikov at google dot com>
- Date: Mon, 31 Oct 2011 14:24:09 -0700
- Subject: Re: Linker garbage collection should not collect unreferenced symbols if they are externally visible and export-dynamic is on
- References: <CAAs8HmzWXQsJcsj=jDdO4VnPDuLqUko7xDOWV3C4oOT7Tkymtw@mail.gmail.com>
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