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]

[committed, PATCH] x86; Don't add elf64-x86-64.lo nor elf64.lo together with elfxx-x86.lo


Don't set r_info and r_sym fields in _bfd_x86_elf_link_hash_table_create.
Instead, set them in _bfd_x86_elf_link_setup_gnu_properties.  We can
avoid adding elf64-x86-64.lo and elf64.lo together with elfxx-x86.lo to
bfd_backends.

	* configure.ac (bfd_backends): Don't add elf64-x86-64.lo nor
	elf64.lo together with elfxx-x86.lo for 64-bit BFD.
	* configure: Regenerated.
	* elf32-i386.c (elf_i386_link_setup_gnu_properties): Set r_info
	and r_sym fields of plt_layout.
	* elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties):
	Likewise.
	* elfxx-x86.c (elf_x86_64_is_reloc_section): Remove BFD64 check.
	(_bfd_x86_elf_link_hash_table_create): Likewise.  Don't set
	r_info nor r_sym fields.
	(_bfd_x86_elf_link_setup_gnu_properties): Set r_info and r_sym
	fields of htab.
	* elfxx-x86.h (elf_x86_plt_layout_table): Add r_info and r_sym.
---
 bfd/ChangeLog      | 16 ++++++++++++++++
 bfd/configure      |  7 -------
 bfd/configure.ac   |  7 -------
 bfd/elf32-i386.c   |  3 +++
 bfd/elf64-x86-64.c | 11 +++++++++++
 bfd/elfxx-x86.c    | 17 +++++------------
 bfd/elfxx-x86.h    |  3 +++
 7 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index d89909b37a..c3144b3363 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,19 @@
+2017-09-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* configure.ac (bfd_backends): Don't add elf64-x86-64.lo nor
+	elf64.lo together with elfxx-x86.lo for 64-bit BFD.
+	* configure: Regenerated.
+	* elf32-i386.c (elf_i386_link_setup_gnu_properties): Set r_info
+	and r_sym fields of plt_layout.
+	* elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties):
+	Likewise.
+	* elfxx-x86.c (elf_x86_64_is_reloc_section): Remove BFD64 check.
+	(_bfd_x86_elf_link_hash_table_create): Likewise.  Don't set
+	r_info nor r_sym fields.
+	(_bfd_x86_elf_link_setup_gnu_properties): Set r_info and r_sym
+	fields of htab.
+	* elfxx-x86.h (elf_x86_plt_layout_table): Add r_info and r_sym.
+
 2017-09-07  Palmer Dabbelt  <palmer@dabbelt.com>
 
 	* (_bfd_riscv_relax_align): Call bfd_set_error and
diff --git a/bfd/configure b/bfd/configure
index f555c62ae0..32ee062e80 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -14758,13 +14758,6 @@ rm -f conftest*
     ;;
 esac
 
-# elfxx-x86.lo needs elf64-x86-64.lo and elf64.lo with 64-bit BFD.
-case "${bfd_backends}-${wordsize}" in
-  *elfxx-x86.lo*-64*)
-    bfd_backends="${bfd_backends} elf64-x86-64.lo elf64.lo"
-    ;;
-esac
-
 tdefaults=""
 test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
 test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
diff --git a/bfd/configure.ac b/bfd/configure.ac
index 1930a41406..0e4c669b7d 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -825,13 +825,6 @@ case ${host64}-${target64}-${want64} in
     ;;
 esac
 
-# elfxx-x86.lo needs elf64-x86-64.lo and elf64.lo with 64-bit BFD.
-case "${bfd_backends}-${wordsize}" in
-  *elfxx-x86.lo*-64*)
-    bfd_backends="${bfd_backends} elf64-x86-64.lo elf64.lo"
-    ;;
-esac
-
 tdefaults=""
 test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
 test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index cee5182c16..a64a09d458 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -4628,6 +4628,9 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
       break;
     }
 
+  plt_layout.r_info = elf32_r_info;
+  plt_layout.r_sym = elf32_r_sym;
+
   return _bfd_x86_elf_link_setup_gnu_properties (info, &plt_layout);
 }
 
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index a2a4be84d6..10da820518 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -5185,6 +5185,17 @@ elf_x86_64_link_setup_gnu_properties (struct bfd_link_info *info)
       plt_layout.normal_target = FALSE;
     }
 
+  if (ABI_64_P (info->output_bfd))
+    {
+      plt_layout.r_info = elf64_r_info;
+      plt_layout.r_sym = elf64_r_sym;
+    }
+  else
+    {
+      plt_layout.r_info = elf32_r_info;
+      plt_layout.r_sym = elf32_r_sym;
+    }
+
   return _bfd_x86_elf_link_setup_gnu_properties (info, &plt_layout);
 }
 
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index 4f6b09e1d0..bbb0578031 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -731,13 +731,11 @@ elf_i386_is_reloc_section (const char *secname)
   return CONST_STRNEQ (secname, ".rel");
 }
 
-#ifdef BFD64
 static bfd_boolean
 elf_x86_64_is_reloc_section (const char *secname)
 {
   return CONST_STRNEQ (secname, ".rela");
 }
-#endif
 
 /* Create an x86 ELF linker hash table.  */
 
@@ -762,8 +760,6 @@ _bfd_x86_elf_link_hash_table_create (bfd *abfd)
       return NULL;
     }
 
-#ifdef BFD64
-  /* NB: If BFD64 isn't defined, only i386 will be supported.  */
   if (bed->target_id == X86_64_ELF_DATA)
     {
       ret->is_reloc_section = elf_x86_64_is_reloc_section;
@@ -775,18 +771,13 @@ _bfd_x86_elf_link_hash_table_create (bfd *abfd)
     }
   if (ABI_64_P (abfd))
     {
-      ret->r_info = elf64_r_info;
-      ret->r_sym = elf64_r_sym;
       ret->sizeof_reloc = sizeof (Elf64_External_Rela);
       ret->pointer_r_type = R_X86_64_64;
       ret->dynamic_interpreter = ELF64_DYNAMIC_INTERPRETER;
       ret->dynamic_interpreter_size = sizeof ELF64_DYNAMIC_INTERPRETER;
     }
   else
-#endif
     {
-      ret->r_info = elf32_r_info;
-      ret->r_sym = elf32_r_sym;
       if (bed->target_id == X86_64_ELF_DATA)
 	{
 	  ret->sizeof_reloc = sizeof (Elf32_External_Rela);
@@ -2188,9 +2179,6 @@ error_alignment:
 
   pbfd = _bfd_elf_link_setup_gnu_properties (info);
 
-  if (bfd_link_relocatable (info))
-    return pbfd;
-
   bed = get_elf_backend_data (info->output_bfd);
 
   htab = elf_x86_hash_table (info, bed->target_id);
@@ -2198,6 +2186,11 @@ error_alignment:
     return pbfd;
 
   htab->is_vxworks = plt_layout->is_vxworks;
+  htab->r_info = plt_layout->r_info;
+  htab->r_sym = plt_layout->r_sym;
+
+  if (bfd_link_relocatable (info))
+    return pbfd;
 
   use_ibt_plt = info->ibtplt || info->ibt;
   if (!use_ibt_plt && pbfd != NULL)
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index 5d0a28a3eb..6e773561f4 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -362,6 +362,9 @@ struct elf_x86_plt_layout_table
 
   /* TRUE if this is a VxWorks x86 target.  */
   bfd_boolean is_vxworks;
+
+  bfd_vma (*r_info) (bfd_vma, bfd_vma);
+  bfd_vma (*r_sym) (bfd_vma);
 };
 
 struct elf_x86_obj_tdata
-- 
2.13.5


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