aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-i386.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-10-06 00:21:48 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-10-06 00:23:00 -0700
commitdaf1c414a48baf090f005ce4b319b6881d5d6872 (patch)
tree3813ba5466b90157df7f6ca27b1beb706b0f0902 /bfd/elf32-i386.c
parent51537393bd939e79f6e9291629fb65a17e6f19da (diff)
downloadgdb-daf1c414a48baf090f005ce4b319b6881d5d6872.zip
gdb-daf1c414a48baf090f005ce4b319b6881d5d6872.tar.gz
gdb-daf1c414a48baf090f005ce4b319b6881d5d6872.tar.bz2
x86: Add NEED_DYNAMIC_RELOCATION_P
Add NEED_DYNAMIC_RELOCATION_P which returns TRUE if dynamic relocation is needed. * elf32-i386.c (X86_PCREL_TYPE_P): New. (elf_i386_check_relocs): Use NEED_DYNAMIC_RELOCATION_P. * elf64-x86-64.c (IS_X86_64_PCREL_TYPE): Renamed to ... (X86_PCREL_TYPE_P): This. (elf_x86_64_check_relocs): Use NEED_DYNAMIC_RELOCATION_P. Replace IS_X86_64_PCREL_TYPE with X86_PCREL_TYPE_P. (elf_x86_64_relocate_section): Replace IS_X86_64_PCREL_TYPE with X86_PCREL_TYPE_P. * elfxx-x86.h (NEED_DYNAMIC_RELOCATION_P): New.
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r--bfd/elf32-i386.c44
1 files changed, 4 insertions, 40 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index c4af6b2..4a3c690 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -182,6 +182,8 @@ static reloc_howto_type elf_howto_table[]=
};
+#define X86_PCREL_TYPE_P(TYPE) ((TYPE) == R_386_PC32)
+
#ifdef DEBUG_GEN_RELOC
#define TRACE(str) \
fprintf (stderr, "i386 bfd reloc lookup %d (%s)\n", code, str)
@@ -1813,46 +1815,8 @@ do_relocation:
size_reloc = FALSE;
do_size:
- /* If we are creating a shared library, and this is a reloc
- against a global symbol, or a non PC relative reloc
- against a local symbol, then we need to copy the reloc
- into the shared library. However, if we are linking with
- -Bsymbolic, we do not need to copy a reloc against a
- global symbol which is defined in an object we are
- including in the link (i.e., DEF_REGULAR is set). At
- this point we have not seen all the input files, so it is
- possible that DEF_REGULAR is not set now but will be set
- later (it is never cleared). In case of a weak definition,
- DEF_REGULAR may be cleared later by a strong definition in
- a shared library. We account for that possibility below by
- storing information in the relocs_copied field of the hash
- table entry. A similar situation occurs when creating
- shared libraries and symbol visibility changes render the
- symbol local.
-
- If on the other hand, we are creating an executable, we
- may need to keep relocations for symbols satisfied by a
- dynamic library if we manage to avoid copy relocs for the
- symbol.
-
- Generate dynamic pointer relocation against STT_GNU_IFUNC
- symbol in the non-code section. */
- if ((bfd_link_pic (info)
- && (r_type != R_386_PC32
- || (h != NULL
- && (! (bfd_link_pie (info)
- || SYMBOLIC_BIND (info, h))
- || h->root.type == bfd_link_hash_defweak
- || !h->def_regular))))
- || (h != NULL
- && h->type == STT_GNU_IFUNC
- && r_type == R_386_32
- && (sec->flags & SEC_CODE) == 0)
- || (ELIMINATE_COPY_RELOCS
- && !bfd_link_pic (info)
- && h != NULL
- && (h->root.type == bfd_link_hash_defweak
- || !h->def_regular)))
+ if (NEED_DYNAMIC_RELOCATION_P (info, h, sec, r_type,
+ R_386_32))
{
struct elf_dyn_relocs *p;
struct elf_dyn_relocs **head;