aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2005-07-26 11:47:05 +0000
committerAlan Modra <amodra@gmail.com>2005-07-26 11:47:05 +0000
commit9e8cc8b4bf949f1246146cc6c857a877e0d454d3 (patch)
tree2ab574b7cf48008d86357cbfadf8bcd2bafa2a20 /bfd/elflink.c
parentc5f5f1f476b0ffa54efbf604ae297dea19ab57c4 (diff)
downloadgdb-9e8cc8b4bf949f1246146cc6c857a877e0d454d3.zip
gdb-9e8cc8b4bf949f1246146cc6c857a877e0d454d3.tar.gz
gdb-9e8cc8b4bf949f1246146cc6c857a877e0d454d3.tar.bz2
* elflink.c (elf_gc_sweep): Move gcc_except_table code..
(bfd_elf_gc_sections): ..to here.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c77
1 files changed, 42 insertions, 35 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index f52d307..067ac3b 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -8912,41 +8912,6 @@ elf_gc_sweep (struct bfd_link_info *info, gc_sweep_hook_fn gc_sweep_hook)
if (o->gc_mark)
continue;
- /* Keep .gcc_except_table.* if the associated .text.* is
- marked. This isn't very nice, but the proper solution,
- splitting .eh_frame up and using comdat doesn't pan out
- easily due to needing special relocs to handle the
- difference of two symbols in separate sections.
- Don't keep code sections referenced by .eh_frame. */
- if (o->gc_mark_from_eh && (o->flags & SEC_CODE) == 0)
- {
- if (strncmp (o->name, ".gcc_except_table.", 18) == 0)
- {
- unsigned long len;
- char *fn_name;
- asection *fn_text;
-
- len = strlen (o->name + 18) + 1;
- fn_name = bfd_malloc (len + 6);
- if (fn_name == NULL)
- return FALSE;
- memcpy (fn_name, ".text.", 6);
- memcpy (fn_name + 6, o->name + 18, len);
- fn_text = bfd_get_section_by_name (sub, fn_name);
- free (fn_name);
- if (fn_text != NULL && fn_text->gc_mark)
- o->gc_mark = 1;
- }
-
- /* If not using specially named exception table section,
- then keep whatever we are using. */
- else
- o->gc_mark = 1;
-
- if (o->gc_mark)
- continue;
- }
-
/* Skip sweeping sections already excluded. */
if (o->flags & SEC_EXCLUDE)
continue;
@@ -9183,6 +9148,48 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
return FALSE;
}
+ /* ... again for sections marked from eh_frame. */
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ {
+ asection *o;
+
+ if (bfd_get_flavour (sub) != bfd_target_elf_flavour)
+ continue;
+
+ /* Keep .gcc_except_table.* if the associated .text.* is
+ marked. This isn't very nice, but the proper solution,
+ splitting .eh_frame up and using comdat doesn't pan out
+ easily due to needing special relocs to handle the
+ difference of two symbols in separate sections.
+ Don't keep code sections referenced by .eh_frame. */
+ for (o = sub->sections; o != NULL; o = o->next)
+ if (!o->gc_mark && o->gc_mark_from_eh && (o->flags & SEC_CODE) == 0)
+ {
+ if (strncmp (o->name, ".gcc_except_table.", 18) == 0)
+ {
+ unsigned long len;
+ char *fn_name;
+ asection *fn_text;
+
+ len = strlen (o->name + 18) + 1;
+ fn_name = bfd_malloc (len + 6);
+ if (fn_name == NULL)
+ return FALSE;
+ memcpy (fn_name, ".text.", 6);
+ memcpy (fn_name + 6, o->name + 18, len);
+ fn_text = bfd_get_section_by_name (sub, fn_name);
+ free (fn_name);
+ if (fn_text == NULL || !fn_text->gc_mark)
+ continue;
+ }
+
+ /* If not using specially named exception table section,
+ then keep whatever we are using. */
+ if (!_bfd_elf_gc_mark (info, o, gc_mark_hook))
+ return FALSE;
+ }
+ }
+
/* ... and mark SEC_EXCLUDE for those that go. */
if (!elf_gc_sweep (info, get_elf_backend_data (abfd)->gc_sweep_hook))
return FALSE;