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]

Patch: ARM disable merging of adjacent exidx unwinder entries


Merging exidx unwinder entries makes stack unwinding in gcj impossible.
This patch adds a new linker switch, --no-merge-exidx-entries, which
turns it off.  I've been quite careful not to affect the anything in
elf32_arm_fix_exidx_coverage except this one thing.

OK to apply?

More info at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40860

Andrew.


2010-04-15  Andrew Haley  <aph@redhat.com>

	* emultempl/armelf.em (merge_exidx_entries): New variable.
	(OPTION_NO_MERGE_EXIDX_ENTRIES): New definition.
	("no-merge-exidx-entries"): New option.
	* ld.texinfo (merge-exidx-entries): Document this option.

2010-04-15  Andrew Haley  <aph@redhat.com>

	* bfd-in.h (elf32_arm_fix_exidx_coverage): Add new flag:
	merge_exidx_entries.
	* bfd-in2.h: Likewise.
	* elf32-arm.c (elf32_arm_fix_exidx_coverage): Likewise.  Use it to
	control merging of exidx entries.
	
2010-04-15  Andrew Haley  <aph@redhat.com>

	* options.h (merge_exidx_entries): New option.
	* arm.cc (class Arm_exidx_fixup): Add new arg, merge_exidx_entries.
	(class Arm_exidx_fixup::merge_exidx_entries_): New member.
	(Output_section::fix_exidx_coverage): Add new arg, merge_exidx_entries.
	(Target_arm::merge_exidx_entries): New function.
	(process_exidx_entry): Don't merge if merge_exidx_entries_ is false.
	(Arm_output_section::fix_exidx_coverage): Pass merge_exidx_entries
	to Arm_exidx_fixup constructor.
	Add new arg, merge_exidx_entries.
	(Target_arm::fix_exidx_coverage): pass merge_exidx_entries to
	Arm_output_section::fix_exidx_coverage.

Index: bfd/bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.150
diff -u -r1.150 bfd-in.h
--- bfd/bfd-in.h	26 Mar 2010 08:34:24 -0000	1.150
+++ bfd/bfd-in.h	15 Apr 2010 17:48:44 -0000
@@ -906,7 +906,7 @@
 
 /* ARM unwind section editing support.  */
 extern bfd_boolean elf32_arm_fix_exidx_coverage
-  (struct bfd_section **, unsigned int, struct bfd_link_info *);
+(struct bfd_section **, unsigned int, struct bfd_link_info *, bfd_boolean);
 
 /* PowerPC @tls opcode transform/validate.  */
 extern unsigned int _bfd_elf_ppc_at_tls_transform
Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.511
diff -u -r1.511 bfd-in2.h
--- bfd/bfd-in2.h	1 Apr 2010 09:47:13 -0000	1.511
+++ bfd/bfd-in2.h	15 Apr 2010 17:48:45 -0000
@@ -913,7 +913,7 @@
 
 /* ARM unwind section editing support.  */
 extern bfd_boolean elf32_arm_fix_exidx_coverage
-  (struct bfd_section **, unsigned int, struct bfd_link_info *);
+  (struct bfd_section **, unsigned int, struct bfd_link_info *, bfd_boolean);
 
 /* PowerPC @tls opcode transform/validate.  */
 extern unsigned int _bfd_elf_ppc_at_tls_transform
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.231
diff -u -r1.231 elf32-arm.c
--- bfd/elf32-arm.c	29 Mar 2010 20:42:55 -0000	1.231
+++ bfd/elf32-arm.c	15 Apr 2010 17:48:46 -0000
@@ -9215,6 +9215,8 @@
      2. Duplicate entries are merged together (EXIDX_CANTUNWIND, or unwind
         codes which have been inlined into the index).
 
+   If MERGE_EXIDX_ENTRIES is false, duplicate entries are not merged.
+
    The edits are applied when the tables are written
    (in elf32_arm_write_section).
 */
@@ -9222,7 +9224,8 @@
 bfd_boolean
 elf32_arm_fix_exidx_coverage (asection **text_section_order,
 			      unsigned int num_text_sections,
-			      struct bfd_link_info *info)
+			      struct bfd_link_info *info,
+			      bfd_boolean merge_exidx_entries)
 {
   bfd *inp;
   unsigned int last_second_word = 0, i;
@@ -9334,7 +9337,8 @@
 	  /* Inlined unwinding data.  Merge if equal to previous.  */
 	  else if ((second_word & 0x80000000) != 0)
 	    {
-	      if (last_second_word == second_word && last_unwind_type == 1)
+	      if (merge_exidx_entries
+		   && last_second_word == second_word && last_unwind_type == 1)
 		elide = 1;
 	      unwind_type = 1;
 	      last_second_word = second_word;
Index: gold/arm.cc
===================================================================
RCS file: /cvs/src/src/gold/arm.cc,v
retrieving revision 1.99
diff -u -r1.99 arm.cc
--- gold/arm.cc	13 Apr 2010 20:37:55 -0000	1.99
+++ gold/arm.cc	15 Apr 2010 17:48:49 -0000
@@ -1226,10 +1226,12 @@
 class Arm_exidx_fixup
 {
  public:
-  Arm_exidx_fixup(Output_section* exidx_output_section)
+  Arm_exidx_fixup(Output_section* exidx_output_section,
+		  bool merge_exidx_entries = true)
     : exidx_output_section_(exidx_output_section), last_unwind_type_(UT_NONE),
       last_inlined_entry_(0), last_input_section_(NULL),
-      section_offset_map_(NULL), first_output_text_section_(NULL)
+      section_offset_map_(NULL), first_output_text_section_(NULL),
+      merge_exidx_entries_(merge_exidx_entries)
   { }
 
   ~Arm_exidx_fixup()
@@ -1301,6 +1303,8 @@
   // Output section for the text section which is linked to the first exidx
   // input in output.
   Output_section* first_output_text_section_;
+
+  bool merge_exidx_entries_;
 };
 
 // Arm output section class.  This is defined mainly to add a number of
@@ -1340,7 +1344,8 @@
   void
   fix_exidx_coverage(Layout* layout,
 		     const Text_section_list& sorted_text_section,
-		     Symbol_table* symtab);
+		     Symbol_table* symtab,
+		     bool merge_exidx_entries);
 
  private:
   // For convenience.
@@ -2261,6 +2266,11 @@
   fix_cortex_a8() const
   { return this->fix_cortex_a8_; }
 
+  // Whether we merge exidx entries in debuginfo.
+  bool
+  merge_exidx_entries() const
+  { return parameters->options().merge_exidx_entries(); }
+
   // Whether we fix R_ARM_V4BX relocation.
   // 0 - do not fix
   // 1 - replace with MOV instruction (armv4 target)
@@ -5186,7 +5196,8 @@
   else if ((second_word & 0x80000000) != 0)
     {
       // Inlined unwinding data.  Merge if equal to previous.
-      delete_entry = (this->last_unwind_type_ == UT_INLINED_ENTRY
+      delete_entry = (merge_exidx_entries_
+		      && this->last_unwind_type_ == UT_INLINED_ENTRY
 		      && this->last_inlined_entry_ == second_word);
       this->last_unwind_type_ = UT_INLINED_ENTRY;
       this->last_inlined_entry_ = second_word;
@@ -5553,7 +5564,8 @@
 Arm_output_section<big_endian>::fix_exidx_coverage(
     Layout* layout,
     const Text_section_list& sorted_text_sections,
-    Symbol_table* symtab)
+    Symbol_table* symtab,
+    bool merge_exidx_entries)
 {
   // We should only do this for the EXIDX output section.
   gold_assert(this->type() == elfcpp::SHT_ARM_EXIDX);
@@ -5585,7 +5597,7 @@
       known_input_sections.insert(Section_id(p->relobj(), p->shndx()));
     }
 
-  Arm_exidx_fixup exidx_fixup(this);
+  Arm_exidx_fixup exidx_fixup(this, merge_exidx_entries);
 
   // Go over the sorted text sections.
   Section_id_set processed_input_sections;
@@ -10882,7 +10894,8 @@
       arm_output_section->append_text_sections_to_list(&sorted_text_sections);
     } 
 
-  exidx_section->fix_exidx_coverage(layout, sorted_text_sections, symtab);
+  exidx_section->fix_exidx_coverage(layout, sorted_text_sections, symtab,
+				    merge_exidx_entries());
 }
 
 Target_selector_arm<false> target_selector_arm;
Index: gold/options.h
===================================================================
RCS file: /cvs/src/src/gold/options.h,v
retrieving revision 1.144
diff -u -r1.144 options.h
--- gold/options.h	7 Apr 2010 21:42:22 -0000	1.144
+++ gold/options.h	15 Apr 2010 17:48:49 -0000
@@ -733,6 +733,10 @@
 	      N_("(ARM only) Fix binaries for Cortex-A8 erratum."),
 	      N_("(ARM only) Do not fix binaries for Cortex-A8 erratum."));
 
+  DEFINE_bool(merge_exidx_entries, options::TWO_DASHES, '\0', true,
+	      N_("(ARM only) Merge exidx entries in debuginfo."),
+	      N_("(ARM only) Do not merge exidx entries in debuginfo."));
+
   DEFINE_special(fix_v4bx, options::TWO_DASHES, '\0',
                  N_("(ARM only) Rewrite BX rn as MOV pc, rn for ARMv4"),
                  NULL);
Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.258
diff -u -r1.258 ld.texinfo
--- ld/ld.texinfo	5 Apr 2010 09:04:08 -0000	1.258
+++ ld/ld.texinfo	15 Apr 2010 17:48:50 -0000
@@ -5939,6 +5939,10 @@
 
 The erratum only affects Thumb-2 code.  Please contact ARM for further details.
 
+@kindex --merge-exidx-entries
+@kindex --no-merge-exidx-entries
+The @samp{--no-merge-exidx-entries} switch disables the merging of adjacent exidx entries in debuginfo.
+
 @ifclear GENERIC
 @lowersections
 @end ifclear
Index: ld/emultempl/armelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/armelf.em,v
retrieving revision 1.78
diff -u -r1.78 armelf.em
--- ld/emultempl/armelf.em	5 Feb 2010 13:57:47 -0000	1.78
+++ ld/emultempl/armelf.em	15 Apr 2010 17:48:50 -0000
@@ -41,6 +41,7 @@
 static int no_enum_size_warning = 0;
 static int no_wchar_size_warning = 0;
 static int pic_veneer = 0;
+static int merge_exidx_entries = -1;
 
 static void
 gld${EMULATION_NAME}_before_parse (void)
@@ -314,7 +315,8 @@
 	
       qsort (sec_list, sec_count, sizeof (asection *), &compare_output_sec_vma);
       
-      if (elf32_arm_fix_exidx_coverage (sec_list, sec_count, &link_info))
+      if (elf32_arm_fix_exidx_coverage (sec_list, sec_count, &link_info,
+					   merge_exidx_entries))
 	need_laying_out = 1;
       
       free (sec_list);
@@ -526,6 +528,7 @@
 #define OPTION_NO_WCHAR_SIZE_WARNING	313
 #define OPTION_FIX_CORTEX_A8		314
 #define OPTION_NO_FIX_CORTEX_A8		315
+#define OPTION_NO_MERGE_EXIDX_ENTRIES   316
 '
 
 PARSE_AND_LIST_SHORTOPTS=p
@@ -547,6 +550,7 @@
   { "no-wchar-size-warning", no_argument, NULL, OPTION_NO_WCHAR_SIZE_WARNING},
   { "fix-cortex-a8", no_argument, NULL, OPTION_FIX_CORTEX_A8 },
   { "no-fix-cortex-a8", no_argument, NULL, OPTION_NO_FIX_CORTEX_A8 },
+  { "no-merge-exidx-entries", no_argument, NULL, OPTION_NO_MERGE_EXIDX_ENTRIES },
 '
 
 PARSE_AND_LIST_OPTIONS='
@@ -574,6 +578,8 @@
                            the linker should choose suitable defaults.\n"
  		   ));
   fprintf (file, _("  --[no-]fix-cortex-a8        Disable/enable Cortex-A8 Thumb-2 branch erratum fix\n"));
+  fprintf (file, _("  --no-merge-exidx-entries    Disable merging exidx entries\n"));
+ 
 '
 
 PARSE_AND_LIST_ARGS_CASES='
@@ -653,6 +659,10 @@
     case OPTION_NO_FIX_CORTEX_A8:
       fix_cortex_a8 = 0;
       break;
+
+   case OPTION_NO_MERGE_EXIDX_ENTRIES:
+      merge_exidx_entries = 0;
+
 '
 
 # We have our own before_allocation etc. functions, but they call


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