This is the mail archive of the binutils-cvs@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]

[binutils-gdb] Gold: Don't fail on R_X86_64_[REX_]GOTPCRELX relocations


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2891b491040ac84dfe0013454b2aa834de7b539c

commit 2891b491040ac84dfe0013454b2aa834de7b539c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Oct 22 04:56:10 2015 -0700

    Gold: Don't fail on R_X86_64_[REX_]GOTPCRELX relocations
    
    This patch updates gold to treat the R_X86_64_GOTPCRELX and
    R_X86_64_REX_GOTPCRELX relocations proposed in
    
    https://groups.google.com/forum/#!topic/x86-64-abi/n9AWHogmVY0
    
    the same as R_X86_64_GOTPCREL.  FIXME: Gold should perform the
    transformations as suggested.
    
    elfcpp/
    
    	* x86_64.h (R_X86_64_GOTPCRELX): New.
    	(R_X86_64_REX_GOTPCRELX): Likewise.
    
    gold/
    
    	* x86_64.cc (Target_x86_64<size>::Scan::get_reference_flags):
    	Treat R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX the same
    	as R_X86_64_GOTPCREL.
    	(Target_x86_64<size>::Scan::local): Likewise.
    	(Target_x86_64<size>::Scan::possible_function_pointer_reloc):
    	Likewise.
    	(Target_x86_64<size>::Scan::global): Likewise.
    	(Target_x86_64<size>::Relocate::relocate): Likewise.
    	(Target_x86_64<size>::Relocatable_size_for_reloc::get_size_for_reloc):
    	Likewise.

Diff:
---
 elfcpp/ChangeLog |  5 +++++
 elfcpp/x86_64.h  |  4 ++++
 gold/ChangeLog   | 13 +++++++++++++
 gold/x86_64.cc   | 20 ++++++++++++++++++--
 4 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/elfcpp/ChangeLog b/elfcpp/ChangeLog
index c0f1698..24df27b 100644
--- a/elfcpp/ChangeLog
+++ b/elfcpp/ChangeLog
@@ -1,5 +1,10 @@
 2015-10-22  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* x86_64.h (R_X86_64_GOTPCRELX): New.
+	(R_X86_64_REX_GOTPCRELX): Likewise.
+
+2015-10-22  H.J. Lu  <hongjiu.lu@intel.com>
+
 	* i386.h (R_386_GOT32X): New.
 
 2015-10-13  H.J. Lu  <hongjiu.lu@intel.com>
diff --git a/elfcpp/x86_64.h b/elfcpp/x86_64.h
index e97ff52..52cb9ae 100644
--- a/elfcpp/x86_64.h
+++ b/elfcpp/x86_64.h
@@ -94,6 +94,10 @@ enum
   R_X86_64_RELATIVE64 = 38,      // 64-bit adjust by program base
   R_X86_64_PC32_BND = 39,  // PC relative 32 bit signed with BND prefix
   R_X86_64_PLT32_BND = 40, // 32 bit PLT address with BND prefix
+  R_X86_64_GOTPCRELX = 41, // 32 bit signed PC relative offset to GOT
+			   // without REX prefix, relaxable.
+  R_X86_64_REX_GOTPCRELX = 42, // 32 bit signed PC relative offset to GOT
+			       // with REX prefix, relaxable.
   // GNU vtable garbage collection extensions.
   R_X86_64_GNU_VTINHERIT = 250,
   R_X86_64_GNU_VTENTRY = 251
diff --git a/gold/ChangeLog b/gold/ChangeLog
index c0af029..46a0636 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,18 @@
 2015-10-22  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* x86_64.cc (Target_x86_64<size>::Scan::get_reference_flags):
+	Treat R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX the same
+	as R_X86_64_GOTPCREL.
+	(Target_x86_64<size>::Scan::local): Likewise.
+	(Target_x86_64<size>::Scan::possible_function_pointer_reloc):
+	Likewise.
+	(Target_x86_64<size>::Scan::global): Likewise.
+	(Target_x86_64<size>::Relocate::relocate): Likewise.
+	(Target_x86_64<size>::Relocatable_size_for_reloc::get_size_for_reloc):
+	Likewise.
+
+2015-10-22  H.J. Lu  <hongjiu.lu@intel.com>
+
 	* i386.cc (Target_i386::Scan::get_reference_flags(): Treat
 	R_386_GOT32X the same as R_386_GOT32.
 	(Target_i386::Scan::local): Likewise.
diff --git a/gold/x86_64.cc b/gold/x86_64.cc
index 007af1d..c728a00 100644
--- a/gold/x86_64.cc
+++ b/gold/x86_64.cc
@@ -2191,6 +2191,8 @@ Target_x86_64<size>::Scan::get_reference_flags(unsigned int r_type)
     case elfcpp::R_X86_64_GOT32:
     case elfcpp::R_X86_64_GOTPCREL64:
     case elfcpp::R_X86_64_GOTPCREL:
+    case elfcpp::R_X86_64_GOTPCRELX:
+    case elfcpp::R_X86_64_REX_GOTPCRELX:
     case elfcpp::R_X86_64_GOTPLT64:
       // Absolute in GOT.
       return Symbol::ABSOLUTE_REF;
@@ -2475,6 +2477,8 @@ Target_x86_64<size>::Scan::local(Symbol_table* symtab,
     case elfcpp::R_X86_64_GOT32:
     case elfcpp::R_X86_64_GOTPCREL64:
     case elfcpp::R_X86_64_GOTPCREL:
+    case elfcpp::R_X86_64_GOTPCRELX:
+    case elfcpp::R_X86_64_REX_GOTPCRELX:
     case elfcpp::R_X86_64_GOTPLT64:
       {
 	// The symbol requires a GOT section.
@@ -2485,7 +2489,9 @@ Target_x86_64<size>::Scan::local(Symbol_table* symtab,
 	// mov foo@GOTPCREL(%rip), %reg
 	// to lea foo(%rip), %reg.
 	// in Relocate::relocate.
-	if (r_type == elfcpp::R_X86_64_GOTPCREL
+	if ((r_type == elfcpp::R_X86_64_GOTPCREL
+	     || r_type == elfcpp::R_X86_64_GOTPCRELX
+	     || r_type == elfcpp::R_X86_64_REX_GOTPCRELX)
 	    && reloc.get_r_offset() >= 2
 	    && !is_ifunc)
 	  {
@@ -2713,6 +2719,8 @@ Target_x86_64<size>::Scan::possible_function_pointer_reloc(unsigned int r_type)
     case elfcpp::R_X86_64_GOT32:
     case elfcpp::R_X86_64_GOTPCREL64:
     case elfcpp::R_X86_64_GOTPCREL:
+    case elfcpp::R_X86_64_GOTPCRELX:
+    case elfcpp::R_X86_64_REX_GOTPCRELX:
     case elfcpp::R_X86_64_GOTPLT64:
       {
 	return true;
@@ -2901,6 +2909,8 @@ Target_x86_64<size>::Scan::global(Symbol_table* symtab,
     case elfcpp::R_X86_64_GOT32:
     case elfcpp::R_X86_64_GOTPCREL64:
     case elfcpp::R_X86_64_GOTPCREL:
+    case elfcpp::R_X86_64_GOTPCRELX:
+    case elfcpp::R_X86_64_REX_GOTPCRELX:
     case elfcpp::R_X86_64_GOTPLT64:
       {
 	// The symbol requires a GOT entry.
@@ -2910,7 +2920,9 @@ Target_x86_64<size>::Scan::global(Symbol_table* symtab,
 	// mov foo@GOTPCREL(%rip), %reg
 	// to lea foo(%rip), %reg.
 	// in Relocate::relocate, then there is nothing to do here.
-	if (r_type == elfcpp::R_X86_64_GOTPCREL
+	if ((r_type == elfcpp::R_X86_64_GOTPCREL
+	     || r_type == elfcpp::R_X86_64_GOTPCRELX
+	     || r_type == elfcpp::R_X86_64_REX_GOTPCRELX)
 	    && reloc.get_r_offset() >= 2
 	    && Target_x86_64<size>::can_convert_mov_to_lea(gsym))
 	  {
@@ -3538,6 +3550,8 @@ Target_x86_64<size>::Relocate::relocate(
       break;
 
     case elfcpp::R_X86_64_GOTPCREL:
+    case elfcpp::R_X86_64_GOTPCRELX:
+    case elfcpp::R_X86_64_REX_GOTPCRELX:
       {
       // Convert
       // mov foo@GOTPCREL(%rip), %reg
@@ -4320,6 +4334,8 @@ Target_x86_64<size>::Relocatable_size_for_reloc::get_size_for_reloc(
     case elfcpp::R_X86_64_GOT64:
     case elfcpp::R_X86_64_GOTPCREL64:
     case elfcpp::R_X86_64_GOTPCREL:
+    case elfcpp::R_X86_64_GOTPCRELX:
+    case elfcpp::R_X86_64_REX_GOTPCRELX:
     case elfcpp::R_X86_64_GOTPLT64:
       return 8;


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