This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fix --gc-sections for Xtensa


The Xtensa property sections were being removed by the linker's --gc-sections option, which was mostly harmless except on Linux where those sections are used to construct the .got.loc table. I've committed this patch to fix it. I tested it by building "busybox" with --gc-sections.

bfd/
	* elf32-xtensa.c (elf_xtensa_gc_mark_hook): Don't follow references
	from Xtensa property sections.
ld/
	* emulparams/elf32xtensa.sh (OTHER_SECTIONS): KEEP property sections.

Index: bfd/elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.83
diff -u -r1.83 elf32-xtensa.c
--- bfd/elf32-xtensa.c	26 Mar 2007 12:23:02 -0000	1.83
+++ bfd/elf32-xtensa.c	12 Apr 2007 15:46:52 -0000
@@ -969,6 +969,19 @@
 			 struct elf_link_hash_entry *h,
 			 Elf_Internal_Sym *sym)
 {
+  /* Property sections are marked "KEEP" in the linker scripts, but they
+     should not cause other sections to be marked.  (This approach relies
+     on elf_xtensa_discard_info to remove property table entries that
+     describe discarded sections.  Alternatively, it might be more
+     efficient to avoid using "KEEP" in the linker scripts and instead use
+     the gc_mark_extra_sections hook to mark only the property sections
+     that describe marked sections.  That alternative does not work well
+     with the current property table sections, which do not correspond
+     one-to-one with the sections they describe, but that should be fixed
+     someday.) */
+  if (xtensa_is_property_section (sec))
+    return NULL;
+
   if (h != NULL)
     switch (ELF32_R_TYPE (rel->r_info))
       {
Index: ld/emulparams/elf32xtensa.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf32xtensa.sh,v
retrieving revision 1.9
diff -u -r1.9 elf32xtensa.sh
--- ld/emulparams/elf32xtensa.sh	11 Oct 2006 22:18:30 -0000	1.9
+++ ld/emulparams/elf32xtensa.sh	12 Apr 2007 15:46:52 -0000
@@ -36,7 +36,7 @@
   }
 "
 OTHER_SECTIONS="
-  .xt.lit       0 : { *(.xt.lit${RELOCATING+ .xt.lit.* .gnu.linkonce.p.*}) }
-  .xt.insn      0 : { *(.xt.insn${RELOCATING+ .gnu.linkonce.x.*}) }
-  .xt.prop      0 : { *(.xt.prop${RELOCATING+ .xt.prop.* .gnu.linkonce.prop.*}) }
+  .xt.lit       0 : { KEEP (*(.xt.lit${RELOCATING+ .xt.lit.* .gnu.linkonce.p.*})) }
+  .xt.insn      0 : { KEEP (*(.xt.insn${RELOCATING+ .gnu.linkonce.x.*})) }
+  .xt.prop      0 : { KEEP (*(.xt.prop${RELOCATING+ .xt.prop.* .gnu.linkonce.prop.*})) }
 "

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]