aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf64-x86-64.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-10-06 00:40:56 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-10-06 00:41:58 -0700
commitaebcc8ffd201adbee973b414818b01876dabe1a0 (patch)
treef1df81a7e76c022163872dfc39268a198ac6ffd2 /bfd/elf64-x86-64.c
parentcf1070f1a1ca1f8be1cd88aa6ece55a25e6a887b (diff)
downloadgdb-aebcc8ffd201adbee973b414818b01876dabe1a0.zip
gdb-aebcc8ffd201adbee973b414818b01876dabe1a0.tar.gz
gdb-aebcc8ffd201adbee973b414818b01876dabe1a0.tar.bz2
x86: Add GENERATE_DYNAMIC_RELOCATION_P
Add GENERATE_DYNAMIC_RELOCATION_P which returns TRUE if dynamic relocation should be generated. * 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. (elf_x86_64_relocate_section): Use GENERATE_DYNAMIC_RELOCATION_P. * elfxx-x86.h (GENERATE_DYNAMIC_RELOCATION_P): New.
Diffstat (limited to 'bfd/elf64-x86-64.c')
-rw-r--r--bfd/elf64-x86-64.c50
1 files changed, 16 insertions, 34 deletions
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index f5ba5a6..b27d4c5 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -206,6 +206,9 @@ static reloc_howto_type x86_64_elf_howto_table[] =
|| ((TYPE) == R_X86_64_PC32_BND) \
|| ((TYPE) == R_X86_64_PC64))
+#define X86_SIZE_TYPE_P(TYPE) \
+ ((TYPE) == R_X86_64_SIZE32 || (TYPE) == R_X86_64_SIZE64)
+
/* Map BFD relocs to the x86_64 elf relocs. */
struct elf_reloc_map
{
@@ -2393,6 +2396,7 @@ elf_x86_64_relocate_section (bfd *output_bfd,
bfd_boolean resolved_to_zero;
bfd_boolean relative_reloc;
bfd_boolean converted_reloc;
+ bfd_boolean need_copy_reloc_in_pie;
r_type = ELF32_R_TYPE (rel->r_info);
if (r_type == (int) R_X86_64_GNU_VTINHERIT
@@ -3085,40 +3089,18 @@ direct:
if ((input_section->flags & SEC_ALLOC) == 0)
break;
- /* Don't copy a pc-relative relocation into the output file
- if the symbol needs copy reloc or the symbol is undefined
- when building executable. Copy dynamic function pointer
- relocations. Don't generate dynamic relocations against
- resolved undefined weak symbols in PIE. */
- if ((bfd_link_pic (info)
- && !(bfd_link_pie (info)
- && h != NULL
- && (h->needs_copy
- || eh->needs_copy
- || h->root.type == bfd_link_hash_undefined)
- && (X86_PCREL_TYPE_P (r_type)
- || r_type == R_X86_64_SIZE32
- || r_type == R_X86_64_SIZE64))
- && (h == NULL
- || ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
- && !resolved_to_zero)
- || h->root.type != bfd_link_hash_undefweak))
- && ((! X86_PCREL_TYPE_P (r_type)
- && r_type != R_X86_64_SIZE32
- && r_type != R_X86_64_SIZE64)
- || ! SYMBOL_CALLS_LOCAL (info, h)))
- || (ELIMINATE_COPY_RELOCS
- && !bfd_link_pic (info)
- && h != NULL
- && h->dynindx != -1
- && (!h->non_got_ref
- || eh->func_pointer_refcount > 0
- || (h->root.type == bfd_link_hash_undefweak
- && !resolved_to_zero))
- && ((h->def_dynamic && !h->def_regular)
- /* Undefined weak symbol is bound locally when
- PIC is false. */
- || h->root.type == bfd_link_hash_undefined)))
+ need_copy_reloc_in_pie = (bfd_link_pie (info)
+ && h != NULL
+ && (h->needs_copy
+ || eh->needs_copy
+ || (h->root.type
+ == bfd_link_hash_undefined))
+ && (X86_PCREL_TYPE_P (r_type)
+ || X86_SIZE_TYPE_P (r_type)));
+
+ if (GENERATE_DYNAMIC_RELOCATION_P (info, eh, r_type,
+ need_copy_reloc_in_pie,
+ resolved_to_zero, FALSE))
{
Elf_Internal_Rela outrel;
bfd_boolean skip, relocate;