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.
This commit is contained in:
H.J. Lu
2017-09-02 07:23:46 -07:00
parent 9ff114ca5d
commit fe53b4a4c4
5 changed files with 35 additions and 20 deletions

View File

@ -853,11 +853,6 @@ static const struct elf_i386_backend_data elf_i386_arch_bed =
#define elf_backend_arch_data &elf_i386_arch_bed
#define is_i386_elf(bfd) \
(bfd_get_flavour (bfd) == bfd_target_elf_flavour \
&& elf_tdata (bfd) != NULL \
&& elf_object_id (bfd) == I386_ELF_DATA)
/* Return TRUE if the TLS access code sequence support transition
from R_TYPE. */
@ -1487,8 +1482,6 @@ elf_i386_check_relocs (bfd *abfd,
if ((sec->flags & SEC_ALLOC) == 0)
return TRUE;
BFD_ASSERT (is_i386_elf (abfd));
htab = elf_x86_hash_table (info, I386_ELF_DATA);
if (htab == NULL)
{
@ -1496,6 +1489,8 @@ elf_i386_check_relocs (bfd *abfd,
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;
@ -2566,7 +2561,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
Elf_Internal_Shdr *symtab_hdr;
asection *srel;
if (! is_i386_elf (ibfd))
if (! is_x86_elf (ibfd, htab))
continue;
for (s = ibfd->sections; s != NULL; s = s->next)
@ -3005,8 +3000,6 @@ elf_i386_relocate_section (bfd *output_bfd,
bfd_boolean is_vxworks_tls;
unsigned plt_entry_size;
BFD_ASSERT (is_i386_elf (input_bfd));
/* Skip if check_relocs failed. */
if (input_section->check_relocs_failed)
return FALSE;
@ -3014,6 +3007,9 @@ elf_i386_relocate_section (bfd *output_bfd,
htab = elf_x86_hash_table (info, I386_ELF_DATA);
if (htab == NULL)
return FALSE;
BFD_ASSERT (is_x86_elf (input_bfd, htab));
symtab_hdr = &elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);
local_got_offsets = elf_local_got_offsets (input_bfd);