aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-ppc.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-ppc.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-ppc.c')
-rw-r--r--bfd/elf32-ppc.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 995e1a9..89c069b 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -2195,9 +2195,6 @@ struct ppc_elf_link_hash_table
/* The type of PLT we have chosen to use. */
enum ppc_elf_plt_type plt_type;
- /* True if the target system is VxWorks. */
- unsigned int is_vxworks:1;
-
/* Whether there exist local gnu indirect function resolvers,
referenced by dynamic relocations. */
unsigned int local_ifunc_resolver:1;
@@ -2335,7 +2332,7 @@ ppc_elf_create_got (bfd *abfd, struct bfd_link_info *info)
return FALSE;
htab = ppc_elf_hash_table (info);
- if (!htab->is_vxworks)
+ if (htab->elf.target_os != is_vxworks)
{
/* The powerpc .got has a blrl instruction in it. Mark it
executable. */
@@ -2495,7 +2492,7 @@ ppc_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
return FALSE;
}
- if (htab->is_vxworks
+ if (htab->elf.target_os == is_vxworks
&& !elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2))
return FALSE;
@@ -2953,7 +2950,7 @@ ppc_elf_check_relocs (bfd *abfd,
tls_type = 0;
r_type = ELF32_R_TYPE (rel->r_info);
ifunc = NULL;
- if (h == NULL && !htab->is_vxworks)
+ if (h == NULL && htab->elf.target_os != is_vxworks)
{
Elf_Internal_Sym *isym = bfd_sym_from_r_symndx (&htab->sym_cache,
abfd, r_symndx);
@@ -2992,7 +2989,7 @@ ppc_elf_check_relocs (bfd *abfd,
}
}
- if (!htab->is_vxworks
+ if (htab->elf.target_os != is_vxworks
&& is_branch_reloc (r_type)
&& h != NULL
&& h == tga)
@@ -4798,7 +4795,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
|| (h->non_got_ref
&& !h->ref_regular_nonweak
&& !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)))
- && !htab->is_vxworks
+ && htab->elf.target_os != is_vxworks
&& !ppc_elf_hash_entry (h)->has_sda_refs
&& !_bfd_elf_readonly_dynrelocs (h))
{
@@ -4884,7 +4881,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
executable. */
if (ELIMINATE_COPY_RELOCS
&& !ppc_elf_hash_entry (h)->has_sda_refs
- && !htab->is_vxworks
+ && htab->elf.target_os != is_vxworks
&& !h->def_regular
&& !alias_readonly_dynrelocs (h))
return TRUE;
@@ -5181,7 +5178,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
}
}
- if (htab->is_vxworks)
+ if (htab->elf.target_os == is_vxworks)
{
struct elf_dyn_relocs **pp;
@@ -5495,7 +5492,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
linker script /DISCARD/, so we'll be discarding
the relocs too. */
}
- else if (htab->is_vxworks
+ else if (htab->elf.target_os == is_vxworks
&& strcmp (p->sec->output_section->name,
".tls_vars") == 0)
{
@@ -5560,7 +5557,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
else
*local_got = (bfd_vma) -1;
- if (htab->is_vxworks)
+ if (htab->elf.target_os == is_vxworks)
continue;
/* Allocate space for calls to local STT_GNU_IFUNC syms in .iplt. */
@@ -5873,7 +5870,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
if (!add_dynamic_entry (DT_TEXTREL, 0))
return FALSE;
}
- if (htab->is_vxworks
+ if (htab->elf.target_os == is_vxworks
&& !elf_vxworks_add_dynamic_entries (output_bfd, info))
return FALSE;
}
@@ -6980,7 +6977,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
sym_hashes = elf_sym_hashes (input_bfd);
/* We have to handle relocations in vxworks .tls_vars sections
specially, because the dynamic loader is 'weird'. */
- is_vxworks_tls = (htab->is_vxworks && bfd_link_pic (info)
+ is_vxworks_tls = (htab->elf.target_os == is_vxworks && bfd_link_pic (info)
&& !strcmp (input_section->output_section->name,
".tls_vars"));
if (input_section->sec_info_type == SEC_INFO_TYPE_TARGET)
@@ -7512,7 +7509,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
}
ifunc = NULL;
- if (!htab->is_vxworks)
+ if (htab->elf.target_os != is_vxworks)
{
struct plt_entry *ent;
@@ -9884,7 +9881,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
switch (dyn.d_tag)
{
case DT_PLTGOT:
- if (htab->is_vxworks)
+ if (htab->elf.target_os == is_vxworks)
s = htab->elf.sgotplt;
else
s = htab->elf.splt;
@@ -9916,7 +9913,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
continue;
default:
- if (htab->is_vxworks
+ if (htab->elf.target_os == is_vxworks
&& elf_vxworks_finish_dynamic_entry (output_bfd, &dyn))
break;
continue;
@@ -9968,7 +9965,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
}
/* Fill in the first entry in the VxWorks procedure linkage table. */
- if (htab->is_vxworks
+ if (htab->elf.target_os == is_vxworks
&& htab->elf.splt != NULL
&& htab->elf.splt->size != 0
&& htab->elf.splt->output_section != bfd_abs_section_ptr)
@@ -10377,6 +10374,9 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
#undef ELF_OSABI
+#undef ELF_TARGET_OS
+#define ELF_TARGET_OS is_vxworks
+
/* VxWorks uses the elf default section flags for .plt. */
static const struct bfd_elf_special_section *
ppc_elf_vxworks_get_sec_type_attr (bfd *abfd, asection *sec)
@@ -10402,7 +10402,6 @@ ppc_elf_vxworks_link_hash_table_create (bfd *abfd)
{
struct ppc_elf_link_hash_table *htab
= (struct ppc_elf_link_hash_table *)ret;
- htab->is_vxworks = 1;
htab->plt_type = PLT_VXWORKS;
htab->plt_entry_size = VXWORKS_PLT_ENTRY_SIZE;
htab->plt_slot_size = VXWORKS_PLT_ENTRY_SIZE;