summaryrefslogtreecommitdiff
path: root/bfd/elf32-i386.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-06-06 06:45:23 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-06-06 06:45:38 -0700
commit90c14f0c3ac0252be955990e0ae120faedfb7b59 (patch)
tree1766e3cb8fa1058b0f2e6fc98c0f29dd68dacac5 /bfd/elf32-i386.c
parent1424c35d071e7d49a4a219c7dee8c88ffd60ddca (diff)
downloadbinutils-gdb-90c14f0c3ac0252be955990e0ae120faedfb7b59.tar.gz
ELF: Add target_os to elf_link_hash_table/elf_backend_data
Add target_os to elf_backend_data to identify target OS. Add target_os, to elf_link_hash_table to identify target OS for linker output. * elf-bfd.h (elf_target_os): New. (elf_link_hash_table): Add target_os. (elf_backend_data): Add target_os. * elf32-arm.c (elf32_arm_link_hash_table): Remove vxworks_p, symbian_p and nacl_p. (create_got_section): Updated. (elf32_arm_create_dynamic_sections): Likewise. (arm_type_of_stub): Likewise. (elf32_arm_create_or_find_stub_sec): Likewise. (elf32_arm_allocate_plt_entry): Likewise. (elf32_arm_populate_plt_entry): Likewise. (elf32_arm_final_link_relocate): Likewise. (elf32_arm_check_relocs): Likewise. (allocate_dynrelocs_for_symbol): Likewise. (elf32_arm_finish_dynamic_symbol): Likewise. (elf32_arm_finish_dynamic_sections): Likewise. (elf32_arm_output_plt_map_1): Likewise. (elf32_arm_output_arch_local_syms): Likewise. (elf32_arm_add_symbol_hook): Likewise. (elf32_arm_nacl_link_hash_table_create): Likewise. (elf32_arm_vxworks_link_hash_table_create): Likewise. (elf32_arm_symbian_link_hash_table_create): Likewise. (ELF_TARGET_OS): New. * elf32-i386.c (elf_i386_arch_bed): Removed. (elf_backend_arch_data): Likewise. (elf_i386_solaris_arch_bed): Likewise. (elf_i386_nacl_arch_bed): Likewise. (elf_i386_vxworks_arch_bed): Likewise. (elf_i386_relocate_section): Updated. (elf_i386_finish_dynamic_sections): Likewise. (elf_i386_get_synthetic_symtab): Likewise. (elf_i386_link_setup_gnu_properties): Likewise. (ELF_TARGET_OS): New. * elf32-mips.c (ELF_TARGET_OS): New. * elf32-ppc.c (ppc_elf_link_hash_table): Remove is_vxworks. (ppc_elf_create_got): Updated. (ppc_elf_create_dynamic_sections): Likewise. (ppc_elf_check_relocs): Likewise. (ppc_elf_adjust_dynamic_symbol): Likewise. (ppc_elf_size_dynamic_sections): Likewise. (ppc_elf_relocate_section): Likewise. (ppc_elf_finish_dynamic_sections): Likewise. (ppc_elf_vxworks_link_hash_table_create): Likewise. (ELF_TARGET_OS): New. * elf32-sh.c (elf_sh_link_hash_table): Remove vxworks_p. (sh_elf_link_hash_table_create): Updated. (sh_elf_create_dynamic_sections): Likewise. (allocate_dynrelocs): Likewise. (sh_elf_size_dynamic_sections): Likewise. (sh_elf_relocate_section): Likewise. (sh_elf_finish_dynamic_symbol): Likewise. (sh_elf_finish_dynamic_sections): Likewise. (ELF_TARGET_OS): New. * elf32-sparc.c (elf32_sparc_vxworks_link_hash_table_create): Removed. (bfd_elf32_bfd_link_hash_table_create): Likewise. (ELF_TARGET_OS): New. * elf64-x86-64.c (elf_x86_64_arch_bed): Removed. (elf_x86_64_solaris_arch_bed): Likewise. (elf_x86_64_nacl_arch_bed): Likewise. (elf_x86_64_finish_dynamic_sections): Updated. (elf_x86_64_get_synthetic_symtab): Likewise. (elf_x86_64_link_setup_gnu_properties): Likewise. (ELF_TARGET_OS): New. * elflink.c (_bfd_elf_link_hash_table_init): Initialize target_o. * elfxx-mips.c (mips_elf_link_hash_table): Remove is_vxworks. (MIPS_ELF_REL_DYN_NAME): Updated. (ELF_MIPS_GP_OFFSET): Likewise. (mips_elf_create_local_got_entry): Likewise. (mips_elf_allocate_dynamic_relocations): Likewise. (mips_elf_count_got_symbols): Likewise. (is_gott_symbol): Likewise. (mips_elf_calculate_relocation): Likewise. (mips_elf_create_dynamic_relocation): Likewise. (_bfd_mips_elf_check_relocs): Likewise. (allocate_dynrelocs): Likewise. (_bfd_mips_elf_adjust_dynamic_symbol): Likewise. (mips_elf_lay_out_got): Likewise. (mips_elf_set_plt_sym_value): Likewise. (_bfd_mips_elf_size_dynamic_sections): Likewise. (_bfd_mips_elf_finish_dynamic_symbol): Likewise. (_bfd_mips_elf_finish_dynamic_sections): Likewise. (_bfd_mips_elf_final_link): Likewise. (_bfd_mips_init_file_header): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_create_dynamic_sections): Likewise. (allocate_dynrelocs): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_relocate_section): Likewise. (_bfd_sparc_elf_finish_dynamic_symbol): Likewise. (sparc_finish_dyn): Likewise. (_bfd_sparc_elf_finish_dynamic_sections): Likewise. * elfxx-target.h (ELF_TARGET_OS): New. (elfNN_bed): Add ELF_TARGET_OS. * elfxx-x86.c (elf_x86_allocate_dynrelocs): Updated. (_bfd_x86_elf_link_hash_table_create): Likewise. (_bfd_x86_elf_size_dynamic_sections): Likewise. (_bfd_x86_elf_finish_dynamic_sections): Likewise. (_bfd_x86_elf_adjust_dynamic_symbol): Likewise. (_bfd_x86_elf_link_setup_gnu_properties): Likewise. * elfxx-x86.h (elf_x86_target_os): Removed. (elf_x86_backend_data): Likewise. (get_elf_x86_backend_data): Likewise. (elf_x86_link_hash_table): Remove target_os.
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r--bfd/elf32-i386.c55
1 files changed, 17 insertions, 38 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index f6f669957c3..6f4f7f47186 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -843,14 +843,6 @@ static const struct elf_x86_non_lazy_plt_layout elf_i386_non_lazy_ibt_plt =
#define PLTRESOLVE_RELOCS 2
#define PLT_NON_JUMP_SLOT_RELOCS 2
-/* These are the standard parameters. */
-static const struct elf_x86_backend_data elf_i386_arch_bed =
- {
- is_normal /* os */
- };
-
-#define elf_backend_arch_data &elf_i386_arch_bed
-
/* Return TRUE if the TLS access code sequence support transition
from R_TYPE. */
@@ -2043,7 +2035,7 @@ elf_i386_relocate_section (bfd *output_bfd,
local_tlsdesc_gotents = elf_x86_local_tlsdesc_gotent (input_bfd);
/* We have to handle relocations in vxworks .tls_vars sections
specially, because the dynamic loader is 'weird'. */
- is_vxworks_tls = (htab->target_os == is_vxworks
+ is_vxworks_tls = (htab->elf.target_os == is_vxworks
&& bfd_link_pic (info)
&& !strcmp (input_section->output_section->name,
".tls_vars"));
@@ -3597,7 +3589,7 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd,
resolved_plt->contents + plt_offset
+ htab->plt.plt_got_offset);
- if (htab->target_os == is_vxworks)
+ if (htab->elf.target_os == is_vxworks)
{
int s, k, reloc_index;
@@ -4015,7 +4007,7 @@ elf_i386_finish_dynamic_sections (bfd *output_bfd,
htab->elf.splt->contents
+ htab->lazy_plt->plt0_got2_offset);
- if (htab->target_os == is_vxworks)
+ if (htab->elf.target_os == is_vxworks)
{
Elf_Internal_Rela rel;
int num_plts = (htab->elf.splt->size
@@ -4156,7 +4148,7 @@ elf_i386_get_synthetic_symtab (bfd *abfd,
lazy_plt = NULL;
non_lazy_ibt_plt = NULL;
lazy_ibt_plt = NULL;
- switch (get_elf_x86_backend_data (abfd)->target_os)
+ switch (get_elf_backend_data (abfd)->target_os)
{
case is_normal:
case is_solaris:
@@ -4170,6 +4162,8 @@ elf_i386_get_synthetic_symtab (bfd *abfd,
case is_nacl:
lazy_plt = &elf_i386_nacl_plt;
break;
+ default:
+ abort ();
}
got_addr = 0;
@@ -4316,7 +4310,7 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
{
struct elf_x86_init_table init_table;
- switch (get_elf_x86_backend_data (info->output_bfd)->target_os)
+ switch (get_elf_backend_data (info->output_bfd)->target_os)
{
case is_normal:
case is_solaris:
@@ -4340,6 +4334,8 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
init_table.lazy_ibt_plt = NULL;
init_table.non_lazy_ibt_plt = NULL;
break;
+ default:
+ abort ();
}
init_table.r_info = elf32_r_info;
@@ -4443,13 +4439,8 @@ elf_i386_fbsd_init_file_header (bfd *abfd, struct bfd_link_info *info)
#undef TARGET_LITTLE_NAME
#define TARGET_LITTLE_NAME "elf32-i386-sol2"
-static const struct elf_x86_backend_data elf_i386_solaris_arch_bed =
- {
- is_solaris /* os */
- };
-
-#undef elf_backend_arch_data
-#define elf_backend_arch_data &elf_i386_solaris_arch_bed
+#undef ELF_TARGET_OS
+#define ELF_TARGET_OS is_solaris
/* Restore default: we cannot use ELFOSABI_SOLARIS, otherwise ELFOSABI_NONE
objects won't be recognized. */
@@ -4575,9 +4566,7 @@ elf32_iamcu_elf_object_p (bfd *abfd)
#undef ELF_MACHINE_CODE
#define ELF_MACHINE_CODE EM_IAMCU
-#undef elf_backend_arch_data
-#define elf_backend_arch_data &elf_i386_arch_bed
-
+#undef ELF_TARGET_OS
#undef ELF_OSABI
#undef elf32_bed
@@ -4704,7 +4693,7 @@ static const bfd_byte elf_i386_nacl_eh_frame_plt[] =
|| PLT_FDE_LENGTH != 36 \
|| PLT_FDE_START_OFFSET != 4 + PLT_CIE_LENGTH + 8 \
|| PLT_FDE_LEN_OFFSET != 4 + PLT_CIE_LENGTH + 12)
-# error "Need elf_x86_backend_data parameters for eh_frame_plt offsets!"
+# error "Need PLT_CIE_LENGTH parameters for eh_frame_plt offsets!"
#endif
PLT_CIE_LENGTH, 0, 0, 0, /* CIE length */
0, 0, 0, 0, /* CIE ID */
@@ -4764,11 +4753,6 @@ static const struct elf_x86_lazy_plt_layout elf_i386_nacl_plt =
sizeof (elf_i386_nacl_eh_frame_plt) /* eh_frame_plt_size */
};
-static const struct elf_x86_backend_data elf_i386_nacl_arch_bed =
- {
- is_nacl /* os */
- };
-
static bfd_boolean
elf32_i386_nacl_elf_object_p (bfd *abfd)
{
@@ -4777,8 +4761,8 @@ elf32_i386_nacl_elf_object_p (bfd *abfd)
return TRUE;
}
-#undef elf_backend_arch_data
-#define elf_backend_arch_data &elf_i386_nacl_arch_bed
+#undef ELF_TARGET_OS
+#define ELF_TARGET_OS is_nacl
#undef elf_backend_object_p
#define elf_backend_object_p elf32_i386_nacl_elf_object_p
@@ -4809,13 +4793,8 @@ elf32_i386_nacl_elf_object_p (bfd *abfd)
#undef elf_backend_plt_alignment
#define elf_backend_plt_alignment 4
-static const struct elf_x86_backend_data elf_i386_vxworks_arch_bed =
- {
- is_vxworks /* os */
- };
-
-#undef elf_backend_arch_data
-#define elf_backend_arch_data &elf_i386_vxworks_arch_bed
+#undef ELF_TARGET_OS
+#define ELF_TARGET_OS is_vxworks
#undef elf_backend_relocs_compatible
#undef elf_backend_add_symbol_hook