[binutils-gdb] x86: Call rtype_to_howto to get reloc_howto_type pointer

H.J.Lu hjl@sourceware.org
Thu Dec 20 21:27:00 GMT 2018


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

commit 76268e027479f587b46b70b69760f1b96204bc28
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Dec 20 13:25:41 2018 -0800

    x86: Call rtype_to_howto to get reloc_howto_type pointer
    
    	* elf32-i386.c (elf_i386_relocate_section): Call
    	elf_i386_rtype_to_howto to get reloc_howto_type pointer.
    	* elf64-x86-64.c (elf_x86_64_relocate_section): Call
    	elf_x86_64_rtype_to_howto to get reloc_howto_type pointer.

Diff:
---
 bfd/ChangeLog      | 7 +++++++
 bfd/elf32-i386.c   | 9 ++-------
 bfd/elf64-x86-64.c | 9 ++-------
 3 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 3485593..70d1abf 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2018-12-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* elf32-i386.c (elf_i386_relocate_section): Call
+	elf_i386_rtype_to_howto to get reloc_howto_type pointer.
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Call
+	elf_x86_64_rtype_to_howto to get reloc_howto_type pointer.
+
 2018-12-18  Alan Modra  <amodra@gmail.com>
 
 	* Makefile.am (bfdinclude_HEADERS): Add bfd_stdint.h.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 7fe6afb..f470b82 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2080,15 +2080,10 @@ elf_i386_relocate_section (bfd *output_bfd,
 	  continue;
 	}
 
-      if ((indx = r_type) >= R_386_standard
-	  && ((indx = r_type - R_386_ext_offset) - R_386_standard
-	      >= R_386_ext - R_386_standard)
-	  && ((indx = r_type - R_386_tls_offset) - R_386_ext
-	      >= R_386_ext2 - R_386_ext))
+      howto = elf_i386_rtype_to_howto (input_bfd, r_type);
+      if (howto == NULL)
 	return _bfd_unrecognized_reloc (input_bfd, input_section, r_type);
 
-      howto = elf_howto_table + indx;
-
       r_symndx = ELF32_R_SYM (rel->r_info);
       h = NULL;
       sym = NULL;
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 8e886b0..204067c 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2443,15 +2443,10 @@ elf_x86_64_relocate_section (bfd *output_bfd,
 	  rel->r_info = htab->r_info (r_symndx, r_type);
 	}
 
-      if (r_type >= (int) R_X86_64_standard)
+      howto = elf_x86_64_rtype_to_howto (input_bfd, r_type);
+      if (howto == NULL)
 	return _bfd_unrecognized_reloc (input_bfd, input_section, r_type);
 
-      if (r_type != (int) R_X86_64_32
-	  || ABI_64_P (output_bfd))
-	howto = x86_64_elf_howto_table + r_type;
-      else
-	howto = (x86_64_elf_howto_table
-		 + ARRAY_SIZE (x86_64_elf_howto_table) - 1);
       h = NULL;
       sym = NULL;
       sec = NULL;



More information about the Binutils-cvs mailing list