From c658516291815dcfa19290644b366d8261c3fab9 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 13 Oct 2009 21:23:00 +0000 Subject: [PATCH] * options.h (class General_options): Add -init and -fini. * layout.cc (Layout::finish_dynamic_section): Emit given init and fini functions. --- gold/ChangeLog | 6 ++++++ gold/layout.cc | 5 ++--- gold/options.h | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gold/ChangeLog b/gold/ChangeLog index 6c533837985..c39e44f16c9 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,9 @@ +2009-10-13 Bernhard Reutner-Fischer + + * options.h (class General_options): Add -init and -fini. + * layout.cc (Layout::finish_dynamic_section): Emit + given init and fini functions. + 2009-10-13 Sriraman Tallam * gc.h (gc_process_relocs): Check if icf is enabled using new diff --git a/gold/layout.cc b/gold/layout.cc index 0e26116bcc8..d198ce24373 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -3096,12 +3096,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 f14582e00b4..1a034423a72 100644 --- a/gold/options.h +++ b/gold/options.h @@ -687,6 +687,9 @@ class General_options N_("Treat warnings as errors"), N_("Do not treat warnings as errors")); + DEFINE_string(fini, options::ONE_DASH, '\0', "_fini", + N_("Call SYMBOL at unload-time"), N_("SYMBOL")); + DEFINE_string(soname, options::ONE_DASH, 'h', NULL, N_("Set shared library name"), N_("FILENAME")); @@ -714,6 +717,9 @@ class General_options DEFINE_special(incremental_unknown, options::TWO_DASHES, '\0', N_("Use timestamps to check files (default)"), NULL); + DEFINE_string(init, options::ONE_DASH, '\0', "_init", + N_("Call SYMBOL at load-time"), N_("SYMBOL")); + DEFINE_special(just_symbols, options::TWO_DASHES, '\0', N_("Read only symbol values from FILE"), N_("FILE")); -- 2.30.2