This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[committed, PATCH] x86: Add COPY_INPUT_RELOC_P
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: binutils at sourceware dot org
- Date: Fri, 6 Oct 2017 00:45:31 -0700
- Subject: [committed, PATCH] x86: Add COPY_INPUT_RELOC_P
- Authentication-results: sourceware.org; auth=none
Add COPY_INPUT_RELOC_P which returns TRUE if input relocation should
be copied to output.
* elfxx-x86.h (COPY_INPUT_RELOC_P): New.
* elf32-i386.c (elf_i386_relocate_section): Use it.
* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
---
bfd/ChangeLog | 6 ++++++
bfd/elf32-i386.c | 7 +------
bfd/elf64-x86-64.c | 9 +--------
bfd/elfxx-x86.h | 9 +++++++++
4 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 0f066026d4..6f2f9a268b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
2017-10-06 H.J. Lu <hongjiu.lu@intel.com>
+ * elfxx-x86.h (COPY_INPUT_RELOC_P): New.
+ * elf32-i386.c (elf_i386_relocate_section): Use it.
+ * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
+
+2017-10-06 H.J. Lu <hongjiu.lu@intel.com>
+
* elf32-i386.c (X86_SIZE_TYPE_P): New.
(elf_i386_relocate_section): Use GENERATE_DYNAMIC_RELOCATION_P.
* elf64-x86-64.c (X86_SIZE_TYPE_P): New.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 0c63d26744..4adb70a0c5 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2778,12 +2778,7 @@ disallow_got32:
if (skip)
memset (&outrel, 0, sizeof outrel);
- else if (h != NULL
- && h->dynindx != -1
- && (r_type == R_386_PC32
- || !(bfd_link_executable (info)
- || SYMBOLIC_BIND (info, h))
- || !h->def_regular))
+ else if (COPY_INPUT_RELOC_P (info, h, r_type))
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
else
{
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index b27d4c5761..fcc7f5574e 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -3126,14 +3126,7 @@ direct:
if (skip)
memset (&outrel, 0, sizeof outrel);
- /* h->dynindx may be -1 if this symbol was marked to
- become local. */
- else if (h != NULL
- && h->dynindx != -1
- && (X86_PCREL_TYPE_P (r_type)
- || !(bfd_link_executable (info)
- || SYMBOLIC_BIND (info, h))
- || ! h->def_regular))
+ else if (COPY_INPUT_RELOC_P (info, h, r_type))
{
outrel.r_info = htab->r_info (h->dynindx, r_type);
outrel.r_addend = rel->r_addend;
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index cef2eba30e..be438c08a3 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -143,6 +143,15 @@
&& (((EH)->elf.def_dynamic && !(EH)->elf.def_regular) \
|| (EH)->elf.root.type == bfd_link_hash_undefined)))
+/* TRUE if this input relocation should be copied to output. H->dynindx
+ may be -1 if this symbol was marked to become local. */
+#define COPY_INPUT_RELOC_P(INFO, H, R_TYPE) \
+ ((H) != NULL \
+ && (H)->dynindx != -1 \
+ && (X86_PCREL_TYPE_P (R_TYPE) \
+ || !(bfd_link_executable (INFO) || SYMBOLIC_BIND ((INFO), (H))) \
+ || !(H)->def_regular))
+
/* TRUE if this is actually a static link, or it is a -Bsymbolic link
and the symbol is defined locally, or the symbol was forced to be
local because of a version file. */
--
2.13.6