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]

Re: gold patch committed: Discard R_xxx_NONE relocations with -r


Daniel Jacobowitz <drow@false.org> writes:

> Am I reading correctly that you will discard R_xxx_NONE against an
> undefined global symbol with ld -r?  If so, that's a problem; some
> other toolchains, and the ARM EABI, specify that NONE relocations are
> valid for dependency marking.  For instance, a file which passes a
> printf format string including floating-point specifiers might include
> a NONE relocation indicating that the floating-point-aware version of
> printf is required.

Thanks.  Good point.  I committed this patch.  This will only discard
R_xxx_NONE relocs for local symbol 0.


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

	* target-reloc.h (Default_scan_relocatable_relocs): Only discard
	r_type == 0 for a local symbol with r_sym == 0.
	(scan_relocatable_relocs): Pass r_sym to
	local_non_section_strategy.
	* reloc.cc (Emit_relocs_strategy::local_non_section_strategy): Add
	r_sym parameter.


Index: reloc.cc
===================================================================
RCS file: /cvs/src/src/gold/reloc.cc,v
retrieving revision 1.39
diff -u -p -r1.39 reloc.cc
--- reloc.cc	15 Nov 2008 01:40:23 -0000	1.39
+++ reloc.cc	12 Dec 2008 16:29:41 -0000
@@ -368,7 +368,7 @@ class Emit_relocs_strategy
  public:
   // A local non-section symbol.
   inline Relocatable_relocs::Reloc_strategy
-  local_non_section_strategy(unsigned int, Relobj*)
+  local_non_section_strategy(unsigned int, Relobj*, unsigned int)
   { return Relocatable_relocs::RELOC_COPY; }
 
   // A local section symbol.
Index: target-reloc.h
===================================================================
RCS file: /cvs/src/src/gold/target-reloc.h,v
retrieving revision 1.30
diff -u -p -r1.30 target-reloc.h
--- target-reloc.h	12 Dec 2008 02:41:39 -0000	1.30
+++ target-reloc.h	12 Dec 2008 16:29:41 -0000
@@ -308,11 +308,11 @@ 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 r_type, Relobj*)
+  local_non_section_strategy(unsigned int r_type, Relobj*, unsigned int r_sym)
   {
     // We assume that relocation type 0 is NONE.  Targets which are
     // different must override.
-    if (r_type == 0)
+    if (r_type == 0 && r_sym == 0)
       return Relocatable_relocs::RELOC_DISCARD;
     return Relocatable_relocs::RELOC_COPY;
   }
@@ -322,10 +322,6 @@ class Default_scan_relocatable_relocs
   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
@@ -352,14 +348,8 @@ 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 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;
-  }
+  global_strategy(unsigned int, Relobj*, unsigned int)
+  { return Relocatable_relocs::RELOC_COPY; }
 };
 
 // Scan relocs during a relocatable link.  This is a default
@@ -429,7 +419,8 @@ scan_relocatable_relocs(
 		  strategy = Relocatable_relocs::RELOC_DISCARD;
 		}
 	      else if (lsym.get_st_type() != elfcpp::STT_SECTION)
-		strategy = scan.local_non_section_strategy(r_type, object);
+		strategy = scan.local_non_section_strategy(r_type, object,
+							   r_sym);
 	      else
 		{
 		  strategy = scan.local_section_strategy(r_type, object);

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