This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: gc sections and .eh_frame
> Anyway, unfortunately the patch doesn't quite work. There are multiple
> input .eh_frame sections, and only the most recently seen one will get its
> dependencies marked.
Oops. Totally broken would be the right wording. :-)
> While it would be good to reuse the loop, I think we're going to have to
> do a separate loop to search for .gcc_except_table*.
Could we not simply move the invocation of _bfd_elf_gc_mark inside the loop?
A new revision is attached.
--
Eric Botcazou
Index: elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.136.2.3
diff -u -p -r1.136.2.3 elflink.c
--- elflink.c 27 Apr 2005 16:47:24 -0000 1.136.2.3
+++ elflink.c 10 Jun 2005 13:42:38 -0000
@@ -9068,6 +9068,8 @@ bfd_elf_gc_sections (bfd *abfd, struct b
gc_mark_hook = get_elf_backend_data (abfd)->gc_mark_hook;
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
{
+ bfd_boolean has_gcc_except_table = FALSE;
+ asection *eh_frame = NULL;
asection *o;
if (bfd_get_flavour (sub) != bfd_target_elf_flavour)
@@ -9081,11 +9083,29 @@ bfd_elf_gc_sections (bfd *abfd, struct b
orphaned FDEs so don't mark sections referenced by the
EH frame section. */
if (strcmp (o->name, ".eh_frame") == 0)
- o->gc_mark = 1;
+ {
+ o->gc_mark = 1;
+ eh_frame = o;
+ }
else if (!_bfd_elf_gc_mark (info, o, gc_mark_hook))
return FALSE;
}
+
+ /* Detect .gcc_except_table.* sections in the input file. */
+ if (!has_gcc_except_table
+ && strncmp (o->name, ".gcc_except_table", 17) == 0)
+ has_gcc_except_table = TRUE;
}
+
+ /* If we have not detected .gcc_except_table.* sections in the input
+ file, that probably means the target uses a specific section for
+ the EH tables. Play safe and let .eh_frame mark the sections it
+ really needs, since we will not be able to do it explicitly. */
+ if (eh_frame && !has_gcc_except_table)
+ {
+ if (!_bfd_elf_gc_mark (info, eh_frame, gc_mark_hook))
+ return FALSE;
+ }
}
/* ... and mark SEC_EXCLUDE for those that go. */