* elflink.c (bfd_elf_gc_sections): Also search for corresponding
authorEric Botcazou <ebotcazou@libertysurf.fr>
Mon, 11 Dec 2006 14:52:13 +0000 (14:52 +0000)
committerEric Botcazou <ebotcazou@libertysurf.fr>
Mon, 11 Dec 2006 14:52:13 +0000 (14:52 +0000)
sections with .gnu.linkonce.t. prefix.

bfd/ChangeLog
bfd/elflink.c

index 6d06afcf49b93e0c8eb4912d752336e714f94831..274ca81531de685e2efcfbdc963602ea74b44aab 100644 (file)
@@ -1,3 +1,8 @@
+2006-12-11  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * elflink.c (bfd_elf_gc_sections): Also search for corresponding
+       sections with .gnu.linkonce.t. prefix.
+
 2006-12-07  Kazu Hirata  <kazu@codesourcery.com>
 
        * elf32-m68k.c: Update uses of EF_M68K_*.
index be018babcf7a5ebafadedd173d3f04bafd6688e1..e7cc0620f42ee7bada7d48635ccdfcb80037e055 100644 (file)
@@ -9809,13 +9809,15 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
       if (bfd_get_flavour (sub) != bfd_target_elf_flavour)
        continue;
 
-      /* Keep .gcc_except_table.* if the associated .text.* is
+      /* Keep .gcc_except_table.* if the associated .text.* (or the
+        associated .gnu.linkonce.t.* if .text.* doesn't exist) 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.  */
 #define TEXT_PREFIX                    ".text."
+#define TEXT_PREFIX2                   ".gnu.linkonce.t."
 #define GCC_EXCEPT_TABLE_PREFIX                ".gcc_except_table."
       for (o = sub->sections; o != NULL; o = o->next)
        if (!o->gc_mark && o->gc_mark_from_eh && (o->flags & SEC_CODE) == 0)
@@ -9825,15 +9827,30 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
                char *fn_name;
                const char *sec_name;
                asection *fn_text;
-               unsigned o_name_prefix_len  = strlen (GCC_EXCEPT_TABLE_PREFIX);
-               unsigned fn_name_prefix_len = strlen (TEXT_PREFIX);
+               unsigned o_name_prefix_len , fn_name_prefix_len, tmp;
 
+               o_name_prefix_len = strlen (GCC_EXCEPT_TABLE_PREFIX);
                sec_name = o->name + o_name_prefix_len;
-               fn_name = bfd_malloc (strlen (sec_name) + fn_name_prefix_len + 1);
+               fn_name_prefix_len = strlen (TEXT_PREFIX);
+               tmp = strlen (TEXT_PREFIX2);
+               if (tmp > fn_name_prefix_len)
+                 fn_name_prefix_len = tmp;
+               fn_name
+                 = bfd_malloc (fn_name_prefix_len + strlen (sec_name) + 1);
                if (fn_name == NULL)
                  return FALSE;
+
+               /* Try the first prefix.  */
                sprintf (fn_name, "%s%s", TEXT_PREFIX, sec_name);
                fn_text = bfd_get_section_by_name (sub, fn_name);
+
+               /* Try the second prefix.  */
+               if (fn_text == NULL)
+                 {
+                   sprintf (fn_name, "%s%s", TEXT_PREFIX2, sec_name);
+                   fn_text = bfd_get_section_by_name (sub, fn_name);
+                 }
+
                free (fn_name);
                if (fn_text == NULL || !fn_text->gc_mark)
                  continue;