aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-sh.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-sh.c
parent1424c35d071e7d49a4a219c7dee8c88ffd60ddca (diff)
downloadgdb-90c14f0c3ac0252be955990e0ae120faedfb7b59.zip
gdb-90c14f0c3ac0252be955990e0ae120faedfb7b59.tar.gz
gdb-90c14f0c3ac0252be955990e0ae120faedfb7b59.tar.bz2
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-sh.c')
-rw-r--r--bfd/elf32-sh.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index dd67046..84afe44 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -2182,9 +2182,6 @@ struct elf_sh_link_hash_table
/* The type of PLT to use. */
const struct elf_sh_plt_info *plt_info;
- /* True if the target system is VxWorks. */
- bfd_boolean vxworks_p;
-
/* True if the target system uses FDPIC. */
bfd_boolean fdpic_p;
};
@@ -2258,7 +2255,6 @@ sh_elf_link_hash_table_create (bfd *abfd)
return NULL;
}
- ret->vxworks_p = vxworks_object_p (abfd);
ret->fdpic_p = fdpic_object_p (abfd);
return &ret->root.root;
@@ -2467,7 +2463,7 @@ sh_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
}
}
- if (htab->vxworks_p)
+ if (htab->root.target_os == is_vxworks)
{
if (!elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2))
return FALSE;
@@ -2688,7 +2684,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
/* We also need to make an entry in the .rel.plt section. */
htab->root.srelplt->size += sizeof (Elf32_External_Rela);
- if (htab->vxworks_p && !bfd_link_pic (info))
+ if (htab->root.target_os == is_vxworks && !bfd_link_pic (info))
{
/* VxWorks executables have a second set of relocations
for each PLT entry. They go in a separate relocation
@@ -2847,7 +2843,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
}
}
- if (htab->vxworks_p)
+ if (htab->root.target_os == is_vxworks)
{
struct elf_dyn_relocs **pp;
@@ -3006,7 +3002,7 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
linker script /DISCARD/, so we'll be discarding
the relocs too. */
}
- else if (htab->vxworks_p
+ else if (htab->root.target_os == is_vxworks
&& strcmp (p->sec->output_section->name,
".tls_vars") == 0)
{
@@ -3250,7 +3246,7 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
return FALSE;
}
}
- if (htab->vxworks_p
+ if (htab->root.target_os == is_vxworks
&& !elf_vxworks_add_dynamic_entries (output_bfd, info))
return FALSE;
}
@@ -3490,7 +3486,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
/* We have to handle relocations in vxworks .tls_vars sections
specially, because the dynamic loader is 'weird'. */
- is_vxworks_tls = (htab && htab->vxworks_p && bfd_link_pic (info)
+ is_vxworks_tls = (htab && htab->root.target_os == is_vxworks && bfd_link_pic (info)
&& !strcmp (input_section->output_section->name,
".tls_vars"));
@@ -6080,7 +6076,7 @@ sh_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
(splt->contents
+ h->plt.offset
+ plt_info->symbol_fields.got_entry));
- if (htab->vxworks_p)
+ if (htab->root.target_os == is_vxworks)
{
unsigned int reachable_plts, plts_per_4k;
int distance;
@@ -6161,7 +6157,7 @@ sh_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
loc = srelplt->contents + plt_index * sizeof (Elf32_External_Rela);
bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
- if (htab->vxworks_p && !bfd_link_pic (info))
+ if (htab->root.target_os == is_vxworks && !bfd_link_pic (info))
{
/* Create the .rela.plt.unloaded relocations for this PLT entry.
Begin by pointing LOC to the first such relocation. */
@@ -6284,7 +6280,7 @@ sh_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
_GLOBAL_OFFSET_TABLE_ is not absolute: it is relative to the
".got" section. */
if (h == htab->root.hdynamic
- || (!htab->vxworks_p && h == htab->root.hgot))
+ || (htab->root.target_os != is_vxworks && h == htab->root.hgot))
sym->st_shndx = SHN_ABS;
return TRUE;
@@ -6325,7 +6321,7 @@ sh_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
switch (dyn.d_tag)
{
default:
- if (htab->vxworks_p
+ if (htab->root.target_os == is_vxworks
&& elf_vxworks_finish_dynamic_entry (output_bfd, &dyn))
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
@@ -6372,7 +6368,7 @@ sh_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
(splt->contents
+ htab->plt_info->plt0_got_fields[i]));
- if (htab->vxworks_p)
+ if (htab->root.target_os == is_vxworks)
{
/* Finalize the .rela.plt.unloaded contents. */
Elf_Internal_Rela rel;
@@ -6773,6 +6769,9 @@ sh_elf_encode_eh_address (bfd *abfd,
#define ELF_MAXPAGESIZE 0x1000
#undef ELF_COMMONPAGESIZE
+#undef ELF_TARGET_OS
+#define ELF_TARGET_OS is_vxworks
+
#include "elf32-target.h"
#endif /* not SH_TARGET_ALREADY_DEFINED */