aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf64-x86-64.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-09-02 07:23:46 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-09-02 07:24:42 -0700
commitfe53b4a4c47df9c0bb2fa7f0de5a241f21cf352c (patch)
tree13bc3da154360da074c04ee5407516b55782ec7c /bfd/elf64-x86-64.c
parent9ff114ca5d2c2753f1ac110f8586d0040c27a7a3 (diff)
downloadgdb-fe53b4a4c47df9c0bb2fa7f0de5a241f21cf352c.zip
gdb-fe53b4a4c47df9c0bb2fa7f0de5a241f21cf352c.tar.gz
gdb-fe53b4a4c47df9c0bb2fa7f0de5a241f21cf352c.tar.bz2
x86: Add is_x86_elf
Share is_x86_elf in elf32-i386.c and elf64-x86-64.c. * elf32-i386.c (is_i386_elf): Removed. (elf_i386_check_relocs): Replace is_i386_elf with is_x86_elf. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. * elf64-x86-64.c (is_x86_64_elf): Removed. (elf_x86_64_check_relocs): Replace is_x86_64_elf with is_x86_elf. (elf_x86_64_size_dynamic_sections): Likewise. (elf_x86_64_relocate_section): Likewise. * elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize target_id. * elfxx-x86.h (elf_x86_link_hash_table): Add target_id. (is_x86_elf): New.
Diffstat (limited to 'bfd/elf64-x86-64.c')
-rw-r--r--bfd/elf64-x86-64.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index dcebd68..7a6e1f1 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -968,11 +968,6 @@ static const struct elf_x86_64_backend_data elf_x86_64_arch_bed =
#define elf_backend_arch_data &elf_x86_64_arch_bed
-#define is_x86_64_elf(bfd) \
- (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
- && elf_tdata (bfd) != NULL \
- && elf_object_id (bfd) == X86_64_ELF_DATA)
-
static bfd_boolean
elf64_x86_64_elf_object_p (bfd *abfd)
{
@@ -1877,8 +1872,6 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
if ((sec->flags & SEC_ALLOC) == 0)
return TRUE;
- BFD_ASSERT (is_x86_64_elf (abfd));
-
htab = elf_x86_hash_table (info, X86_64_ELF_DATA);
if (htab == NULL)
{
@@ -1886,6 +1879,8 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
return FALSE;
}
+ BFD_ASSERT (is_x86_elf (abfd, htab));
+
/* Get the section contents. */
if (elf_section_data (sec)->this_hdr.contents != NULL)
contents = elf_section_data (sec)->this_hdr.contents;
@@ -2971,7 +2966,7 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd,
Elf_Internal_Shdr *symtab_hdr;
asection *srel;
- if (! is_x86_64_elf (ibfd))
+ if (! is_x86_elf (ibfd, htab))
continue;
for (s = ibfd->sections; s != NULL; s = s->next)
@@ -3395,8 +3390,6 @@ elf_x86_64_relocate_section (bfd *output_bfd,
Elf_Internal_Rela *relend;
unsigned int plt_entry_size;
- BFD_ASSERT (is_x86_64_elf (input_bfd));
-
/* Skip if check_relocs failed. */
if (input_section->check_relocs_failed)
return FALSE;
@@ -3404,6 +3397,9 @@ elf_x86_64_relocate_section (bfd *output_bfd,
htab = elf_x86_hash_table (info, X86_64_ELF_DATA);
if (htab == NULL)
return FALSE;
+
+ BFD_ASSERT (is_x86_elf (input_bfd, htab));
+
plt_entry_size = htab->plt.plt_entry_size;
symtab_hdr = &elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);