From 9e8cc8b4bf949f1246146cc6c857a877e0d454d3 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 26 Jul 2005 11:47:05 +0000 Subject: [PATCH] * elflink.c (elf_gc_sweep): Move gcc_except_table code.. (bfd_elf_gc_sections): ..to here. --- bfd/ChangeLog | 13 ++++++---- bfd/elflink.c | 77 ++++++++++++++++++++++++++++++++--------------------------- 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index bc71060..4276dd8 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2005-07-26 Alan Modra + + * elflink.c (elf_gc_sweep): Move gcc_except_table code.. + (bfd_elf_gc_sections): ..to here. + 2005-07-25 DJ Delorie * reloc.c: Remove unused M32C relocs, add BFD_RELOC_M32C_HI8. @@ -114,10 +119,10 @@ 2005-07-18 Nick Clifton * config.bfd: Move m32c entry to correct location. - * archures.c: Likewise. - * configure.in: Likewise. - * configure: Regenerate. - * targets.c: Move ms1 vector to correct location. + * archures.c: Likewise. + * configure.in: Likewise. + * configure: Regenerate. + * targets.c: Move ms1 vector to correct location. 2005-07-18 Jan Beulich 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; -- 2.7.4