This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[GOLD] Fix _init and _fini garbage collect
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Tue, 16 Oct 2012 10:36:19 +1030
- Subject: [GOLD] Fix _init and _fini garbage collect
Fixes a bug seen during mainline gcc bootstrap on powerpc64. When
building libstdc++, the version script forces _init (and _fini) local,
so these symbols are not exported and the gc_mark_symbol at the end of
symtab.cc:add_from_relobj is not called. On powerpc64 this results in
crti.o .opd section being discarded which in turn results in _init and
DT_INIT having a value of zero. _init code would be discarded on
powerpc64 and other targets if crti.o was built with
-ffunction-sections. OK to apply?
PR gold/14726
* gold.cc (queue_middle_tasks): Call gc_mark_symbol on _init and _fini.
Index: gold/gold.cc
===================================================================
RCS file: /cvs/src/src/gold/gold.cc,v
retrieving revision 1.102
diff -u -p -r1.102 gold.cc
--- gold/gold.cc 9 Sep 2012 03:43:51 -0000 1.102
+++ gold/gold.cc 15 Oct 2012 23:24:51 -0000
@@ -502,9 +502,15 @@ queue_middle_tasks(const General_options
if (parameters->options().gc_sections())
{
// Find the start symbol if any.
- Symbol* start_sym = symtab->lookup(parameters->entry());
- if (start_sym != NULL)
- symtab->gc_mark_symbol(start_sym);
+ Symbol* sym = symtab->lookup(parameters->entry());
+ if (sym != NULL)
+ symtab->gc_mark_symbol(sym);
+ sym = symtab->lookup(parameters->options().init());
+ if (sym != NULL && sym->is_defined() && !sym->is_from_dynobj())
+ symtab->gc_mark_symbol(sym);
+ sym = symtab->lookup(parameters->options().fini());
+ if (sym != NULL && sym->is_defined() && !sym->is_from_dynobj())
+ symtab->gc_mark_symbol(sym);
// Symbols named with -u should not be considered garbage.
symtab->gc_mark_undef_symbols(layout);
gold_assert(symtab->gc() != NULL);
--
Alan Modra
Australia Development Lab, IBM