This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
fix Xtensa ld's handling of XCC exception tables
- From: Bob Wilson <bwilson at tensilica dot com>
- To: binutils at sources dot redhat dot com
- Date: Thu, 12 Oct 2006 15:01:06 -0700
- Subject: fix Xtensa ld's handling of XCC exception tables
Tensilica's XCC compiler uses its own format for C++ exception tables. These
tables go in .xt_except_table and .xt_except_desc sections, or the
.gnu.linkonce.e.* and .gnu.linkonce.h.* versions. (Yes, ".e" and ".h" were not
very good choices for those section names, but they're hard to change now.)
I've committed this patch to make ld ignore relocations from these tables to
text that is not included in the link.
bfd/
* elf32-xtensa.c (elf_xtensa_action_discarded): New.
(elf_backend_action_discarded): Define.
ld/
* emultempl/xtensaelf.em (is_inconsistent_linkonce_section): Check
for linkonce XCC exception tables (".e" and ".h").
Index: bfd/elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.72
diff -u -r1.72 elf32-xtensa.c
--- bfd/elf32-xtensa.c 11 Oct 2006 22:16:50 -0000 1.72
+++ bfd/elf32-xtensa.c 12 Oct 2006 18:55:09 -0000
@@ -2969,6 +2969,19 @@
return xtensa_is_property_section (sec);
}
+
+static unsigned int
+elf_xtensa_action_discarded (asection *sec)
+{
+ if (strcmp (".xt_except_table", sec->name) == 0)
+ return 0;
+
+ if (strcmp (".xt_except_desc", sec->name) == 0)
+ return 0;
+
+ return _bfd_elf_default_action_discarded (sec);
+}
+
/* Support for core dump NOTE sections. */
@@ -9832,5 +9845,6 @@
#define elf_backend_relocate_section elf_xtensa_relocate_section
#define elf_backend_size_dynamic_sections elf_xtensa_size_dynamic_sections
#define elf_backend_special_sections elf_xtensa_special_sections
+#define elf_backend_action_discarded elf_xtensa_action_discarded
#include "elf32-target.h"
Index: ld/emultempl/xtensaelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/xtensaelf.em,v
retrieving revision 1.15
diff -u -r1.15 xtensaelf.em
--- ld/emultempl/xtensaelf.em 16 Sep 2006 18:12:16 -0000 1.15
+++ ld/emultempl/xtensaelf.em 12 Oct 2006 18:55:09 -0000
@@ -1184,7 +1184,7 @@
}
-/* Strip out any linkonce literal sections or property tables where the
+/* Strip out any linkonce property tables or XCC exception tables where the
associated linkonce text is from a different object file. Normally,
a matching set of linkonce sections is taken from the same object file,
but sometimes the files are compiled differently so that some of the
@@ -1199,17 +1199,22 @@
{
bfd *abfd = sec->owner;
const char *sec_name = bfd_get_section_name (abfd, sec);
- const char *name = 0;
+ const char *name;
if ((bfd_get_section_flags (abfd, sec) & SEC_LINK_ONCE) == 0
|| strncmp (sec_name, ".gnu.linkonce.", linkonce_len) != 0)
return FALSE;
- /* Check if this is an Xtensa property section. */
- if (CONST_STRNEQ (sec_name + linkonce_len, "p."))
- name = sec_name + linkonce_len + 2;
- else if (CONST_STRNEQ (sec_name + linkonce_len, "prop."))
- name = strchr (sec_name + linkonce_len + 5, '.') + 1;
+ /* Check if this is an Xtensa property section or an exception table
+ for Tensilica's XCC compiler. */
+ name = sec_name + linkonce_len;
+ if (CONST_STRNEQ (name, "prop."))
+ name = strchr (name + 5, '.') + 1;
+ else if (name[1] == '.'
+ && (name[0] == 'p' || name[0] == 'e' || name[0] == 'h'))
+ name += 2;
+ else
+ name = 0;
if (name)
{