This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[ping] [PATCH] gold: implement -init and -fini
- From: Bernhard Reutner-Fischer <rep dot dot dot nop at gmail dot com>
- To: binutils at sources dot redhat dot com
- Cc: iant at google dot com
- Date: Tue, 13 Oct 2009 20:16:39 +0200
- Subject: [ping] [PATCH] gold: implement -init and -fini
- References: <1255042238-18383-1-git-send-email-rep.dot.nop@gmail.com>
Ping.
Would be nice if this would end up in 2.20 ..
thanks,
On Fri, Oct 09, 2009 at 12:50:38AM +0200, Bernhard Reutner-Fischer wrote:
>gold/ChangeLog
>
>2009-10-09 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
>
> * options.h (class General_options): Add -init and -fini.
> * layout.cc (Layout::finish_dynamic_section): Emit
> given init and fini functions.
>
>Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
>---
> gold/layout.cc | 5 ++---
> gold/options.h | 4 ++++
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
>diff --git a/gold/layout.cc b/gold/layout.cc
>index 1b836de..e686650 100644
>--- a/gold/layout.cc
>+++ b/gold/layout.cc
>@@ -3091,12 +3091,11 @@ Layout::finish_dynamic_section(const Input_objects* input_objects,
> odyn->add_string(elfcpp::DT_SONAME, soname);
> }
>
>- // FIXME: Support --init and --fini.
>- Symbol* sym = symtab->lookup("_init");
>+ Symbol* sym = symtab->lookup(parameters->options().init());
> if (sym != NULL && sym->is_defined() && !sym->is_from_dynobj())
> odyn->add_symbol(elfcpp::DT_INIT, sym);
>
>- sym = symtab->lookup("_fini");
>+ sym = symtab->lookup(parameters->options().fini());
> if (sym != NULL && sym->is_defined() && !sym->is_from_dynobj())
> odyn->add_symbol(elfcpp::DT_FINI, sym);
>
>diff --git a/gold/options.h b/gold/options.h
>index f590630..c42a1f1 100644
>--- a/gold/options.h
>+++ b/gold/options.h
>@@ -586,6 +586,10 @@ class General_options
> DEFINE_string(format, options::TWO_DASHES, 'b', "elf",
> N_("Set input format"), ("[elf,binary]"));
>
>+ DEFINE_string(init, options::ONE_DASH, '\0', "_init",
>+ N_("Call SYMBOL at load-time"), N_("SYMBOL"));
>+ DEFINE_string(fini, options::ONE_DASH, '\0', "_fini",
>+ N_("Call SYMBOL at unload-time"), N_("SYMBOL"));
> DEFINE_bool(Bdynamic, options::ONE_DASH, '\0', true,
> N_("-l searches for shared libraries"), NULL);
> DEFINE_bool_alias(Bstatic, Bdynamic, options::ONE_DASH, '\0',
>--
>1.6.3.3
>