aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2015-04-09 18:38:03 +0930
committerAlan Modra <amodra@gmail.com>2015-04-10 10:27:03 +0930
commit6166ed9330a9afd41859d5a716cb9019c338a8ca (patch)
tree4efba2cc9b171965fb04abedbe0d86d013d5a482
parent4f0d8f2d9f95ae5620e70c8b490fe6f534ffd5ce (diff)
downloadgdb-6166ed9330a9afd41859d5a716cb9019c338a8ca.zip
gdb-6166ed9330a9afd41859d5a716cb9019c338a8ca.tar.gz
gdb-6166ed9330a9afd41859d5a716cb9019c338a8ca.tar.bz2
Mark _init and _fini for --gc-sections
gold marks _init and _fini via symbol, ld marks them via section (default scripts set .init and .fini section KEEP). This makes it possible for people to write their own _init and not bother to put the function into the right section. PR ld/18223 * ldlang.c (lang_process): Add _init and _fini to gc_sym_list.
-rw-r--r--ld/ChangeLog5
-rw-r--r--ld/ldlang.c16
2 files changed, 21 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 9e79980..b4d3ceb 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-10 Alan Modra <amodra@gmail.com>
+
+ PR ld/18223
+ * ldlang.c (lang_process): Add _init and _fini to gc_sym_list.
+
2015-04-09 H.J. Lu <hongjiu.lu@intel.com>
* emulparams/elf_x86_64.sh (BNDPLT): Removed.
diff --git a/ld/ldlang.c b/ld/ldlang.c
index cbd5bc3..b074169 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -6692,6 +6692,22 @@ lang_process (void)
link_info.gc_sym_list = &entry_symbol;
if (entry_symbol.name == NULL)
link_info.gc_sym_list = ldlang_undef_chain_list_head;
+ if (link_info.init_function != NULL)
+ {
+ struct bfd_sym_chain *sym
+ = (struct bfd_sym_chain *) stat_alloc (sizeof (*sym));
+ sym->next = link_info.gc_sym_list;
+ sym->name = link_info.init_function;
+ link_info.gc_sym_list = sym;
+ }
+ if (link_info.fini_function != NULL)
+ {
+ struct bfd_sym_chain *sym
+ = (struct bfd_sym_chain *) stat_alloc (sizeof (*sym));
+ sym->next = link_info.gc_sym_list;
+ sym->name = link_info.fini_function;
+ link_info.gc_sym_list = sym;
+ }
ldemul_after_open ();
if (config.map_file != NULL)