This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[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, Bernhard Reutner-Fischer <rep dot dot dot nop at gmail dot com>
- Date: Fri, 9 Oct 2009 00:50:38 +0200
- Subject: [PATCH] gold: implement -init and -fini
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