* elflink.c (elf_gc_sweep): Move gcc_except_table code..
authorAlan Modra <amodra@gmail.com>
Tue, 26 Jul 2005 11:47:05 +0000 (11:47 +0000)
committerAlan Modra <amodra@gmail.com>
Tue, 26 Jul 2005 11:47:05 +0000 (11:47 +0000)
(bfd_elf_gc_sections): ..to here.

bfd/ChangeLog
bfd/elflink.c

index bc710606746cc1bbd9ae2a38ce101de9a19cbd9a..4276dd8843c149fedcbef7c463a15c0b3ced5442 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-26  Alan Modra  <amodra@bigpond.net.au>
+
+       * elflink.c (elf_gc_sweep): Move gcc_except_table code..
+       (bfd_elf_gc_sections): ..to here.
+
 2005-07-25  DJ Delorie  <dj@redhat.com>
 
        * reloc.c: Remove unused M32C relocs, add BFD_RELOC_M32C_HI8.
 2005-07-18  Nick Clifton  <nickc@redhat.com>
 
        * 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  <jbeulich@novell.com>
 
index f52d3070ca2490bf7e5342563677cdbaa4c8b44b..067ac3b703dc736970ba67e52311db13aeba4a7d 100644 (file)
@@ -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;