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]

gold patch committed: Discard R_xxx_NONE relocations with -r


PR 7091 is about a case in which gold crashes because it can not get
the output symbol index of input symbol 0.  While I don't have an
actual test case for this, this appears to be happening because of
R_386_NONE relocations in the input files.  Those relocations may be
discarded when linking with -r.  I committed this patch to do that.

Ian


2008-12-11  Ian Lance Taylor  <iant@google.com>

	PR 7091
	* target-reloc.h (Default_scan_relocatable_relocs): For each
	function, map r_type == 0 to RELOC_DISCARD.


Index: target-reloc.h
===================================================================
RCS file: /cvs/src/src/gold/target-reloc.h,v
retrieving revision 1.29
diff -u -p -r1.29 target-reloc.h
--- target-reloc.h	29 Sep 2008 21:10:26 -0000	1.29
+++ target-reloc.h	12 Dec 2008 02:40:25 -0000
@@ -308,14 +308,24 @@ class Default_scan_relocatable_relocs
   // Return the strategy to use for a local symbol which is not a
   // section symbol, given the relocation type.
   inline Relocatable_relocs::Reloc_strategy
-  local_non_section_strategy(unsigned int, Relobj*)
-  { return Relocatable_relocs::RELOC_COPY; }
+  local_non_section_strategy(unsigned int r_type, Relobj*)
+  {
+    // We assume that relocation type 0 is NONE.  Targets which are
+    // different must override.
+    if (r_type == 0)
+      return Relocatable_relocs::RELOC_DISCARD;
+    return Relocatable_relocs::RELOC_COPY;
+  }
 
   // Return the strategy to use for a local symbol which is a section
   // symbol, given the relocation type.
   inline Relocatable_relocs::Reloc_strategy
   local_section_strategy(unsigned int r_type, Relobj* object)
   {
+    // We assume that relocation type 0 is NONE.  Targets which are
+    // different must override.
+    if (r_type == 0)
+      return Relocatable_relocs::RELOC_DISCARD;
     if (sh_type == elfcpp::SHT_RELA)
       return Relocatable_relocs::RELOC_ADJUST_FOR_SECTION_RELA;
     else
@@ -342,8 +352,14 @@ class Default_scan_relocatable_relocs
   // Return the strategy to use for a global symbol, given the
   // relocation type, the object, and the symbol index.
   inline Relocatable_relocs::Reloc_strategy
-  global_strategy(unsigned int, Relobj*, unsigned int)
-  { return Relocatable_relocs::RELOC_COPY; }
+  global_strategy(unsigned int r_type, Relobj*, unsigned int)
+  {
+    // We assume that relocation type 0 is NONE.  Targets which are
+    // different must override.
+    if (r_type == 0)
+      return Relocatable_relocs::RELOC_DISCARD;
+    return Relocatable_relocs::RELOC_COPY;
+  }
 };
 
 // Scan relocs during a relocatable link.  This is a default

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