diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-06-06 06:45:23 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-06-06 06:45:38 -0700 |
commit | 90c14f0c3ac0252be955990e0ae120faedfb7b59 (patch) | |
tree | 1766e3cb8fa1058b0f2e6fc98c0f29dd68dacac5 /bfd | |
parent | 1424c35d071e7d49a4a219c7dee8c88ffd60ddca (diff) | |
download | gdb-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')
-rw-r--r-- | bfd/ChangeLog | 108 | ||||
-rw-r--r-- | bfd/elf-bfd.h | 15 | ||||
-rw-r--r-- | bfd/elf32-arm.c | 109 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 55 | ||||
-rw-r--r-- | bfd/elf32-mips.c | 3 | ||||
-rw-r--r-- | bfd/elf32-ppc.c | 37 | ||||
-rw-r--r-- | bfd/elf32-sh.c | 29 | ||||
-rw-r--r-- | bfd/elf32-sparc.c | 24 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 33 | ||||
-rw-r--r-- | bfd/elflink.c | 1 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 120 | ||||
-rw-r--r-- | bfd/elfxx-sparc.c | 29 | ||||
-rw-r--r-- | bfd/elfxx-target.h | 5 | ||||
-rw-r--r-- | bfd/elfxx-x86.c | 20 | ||||
-rw-r--r-- | bfd/elfxx-x86.h | 21 |
15 files changed, 338 insertions, 271 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 949bcec..0fb6637 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,111 @@ +2020-06-06 H.J. Lu <hongjiu.lu@intel.com> + + * 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. + 2020-06-06 Alan Modra <amodra@gmail.com> * reloc.c: Rename diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index fbdd19b..3736ba6 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -540,6 +540,15 @@ struct bfd_link_needed_list const char *name; }; +enum elf_target_os +{ + is_normal, + is_symbian, /* Symbian OS. */ + is_solaris, /* Solaris. */ + is_vxworks, /* VxWorks. */ + is_nacl /* Native Client. */ +}; + /* ELF linker hash table. */ struct elf_link_hash_table @@ -641,6 +650,9 @@ struct elf_link_hash_table asection *tls_sec; bfd_size_type tls_size; /* Bytes. */ + /* Target OS for linker output. */ + enum elf_target_os target_os; + /* A linked list of dynamic BFD's loaded in the link. */ struct elf_link_loaded_list *dyn_loaded; @@ -861,6 +873,9 @@ struct elf_backend_data extensions to elf_obj_tdata and elf_link_hash_table structures. */ enum elf_target_id target_id; + /* Target OS. */ + enum elf_target_os target_os; + /* The ELF machine code (EM_xxxx) for this backend. */ int elf_machine_code; diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 8d184b5..f2ac094 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -3360,15 +3360,6 @@ struct elf32_arm_link_hash_table /* The number of bytes in the subsequent PLT etries. */ bfd_size_type plt_entry_size; - /* True if the target system is VxWorks. */ - int vxworks_p; - - /* True if the target system is Symbian OS. */ - int symbian_p; - - /* True if the target system is Native Client. */ - int nacl_p; - /* True if the target uses REL relocations. */ bfd_boolean use_rel; @@ -3803,7 +3794,7 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info) return FALSE; /* BPABI objects never have a GOT, or associated sections. */ - if (htab->symbian_p) + if (htab->root.target_os == is_symbian) return TRUE; if (! _bfd_elf_create_got_section (dynobj, info)) @@ -3960,7 +3951,7 @@ elf32_arm_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) if (!_bfd_elf_create_dynamic_sections (dynobj, info)) return FALSE; - if (htab->vxworks_p) + if (htab->root.target_os == is_vxworks) { if (!elf_vxworks_create_dynamic_sections (dynobj, info, &htab->srelplt2)) return FALSE; @@ -4483,11 +4474,11 @@ arm_type_of_stub (struct bfd_link_info *info, ? (r_type == R_ARM_TLS_CALL /* TLS PIC Stub. */ ? arm_stub_long_branch_any_tls_pic - : (globals->nacl_p + : (globals->root.target_os == is_nacl ? arm_stub_long_branch_arm_nacl_pic : arm_stub_long_branch_any_arm_pic)) /* non-PIC stubs. */ - : (globals->nacl_p + : (globals->root.target_os == is_nacl ? arm_stub_long_branch_arm_nacl : arm_stub_long_branch_any_any); } @@ -4752,7 +4743,7 @@ elf32_arm_create_or_find_stub_sec (asection **link_sec_p, asection *section, stub_sec_p = &htab->stub_group[link_sec->id].stub_sec; stub_sec_prefix = link_sec->name; out_sec = link_sec->output_section; - align = htab->nacl_p ? 4 : 3; + align = htab->root.target_os == is_nacl ? 4 : 3; } if (*stub_sec_p == NULL) @@ -9524,7 +9515,7 @@ elf32_arm_allocate_plt_entry (struct bfd_link_info *info, sgotplt = htab->root.igotplt; /* NaCl uses a special first entry in .iplt too. */ - if (htab->nacl_p && splt->size == 0) + if (htab->root.target_os == is_nacl && splt->size == 0) splt->size += htab->plt_header_size; /* Allocate room for an R_ARM_IRELATIVE relocation in .rel.iplt. */ @@ -9566,7 +9557,7 @@ elf32_arm_allocate_plt_entry (struct bfd_link_info *info, root_plt->offset = splt->size; splt->size += htab->plt_entry_size; - if (!htab->symbian_p) + if (htab->root.target_os != is_symbian) { /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ @@ -9647,7 +9638,7 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info, BFD_ASSERT (splt != NULL && srel != NULL); /* Fill in the entry in the procedure linkage table. */ - if (htab->symbian_p) + if (htab->root.target_os == is_symbian) { BFD_ASSERT (dynindx >= 0); put_arm_insn (htab, output_bfd, @@ -9704,7 +9695,7 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info, + root_plt->offset); ptr = splt->contents + root_plt->offset; - if (htab->vxworks_p && bfd_link_pic (info)) + if (htab->root.target_os == is_vxworks && bfd_link_pic (info)) { unsigned int i; bfd_vma val; @@ -9722,7 +9713,7 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info, put_arm_insn (htab, output_bfd, val, ptr); } } - else if (htab->vxworks_p) + else if (htab->root.target_os == is_vxworks) { unsigned int i; bfd_vma val; @@ -9760,7 +9751,7 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info, rel.r_addend = 0; SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); } - else if (htab->nacl_p) + else if (htab->root.target_os == is_nacl) { /* Calculate the displacement between the PLT slot and the common tail that's part of the special initial PLT slot. */ @@ -10465,7 +10456,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, return bfd_reloc_ok; case R_ARM_ABS12: - if (!globals->vxworks_p) + if (globals->root.target_os != is_vxworks) return elf32_arm_abs12_reloc (input_bfd, hit_data, value + addend); /* Fall through. */ @@ -10513,7 +10504,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, || globals->root.is_relocatable_executable || globals->fdpic_p) && (input_section->flags & SEC_ALLOC) - && !(globals->vxworks_p + && !(globals->root.target_os == is_vxworks && strcmp (input_section->output_section->name, ".tls_vars") == 0) && ((r_type != R_ARM_REL32 && r_type != R_ARM_REL32_NOI) @@ -10590,7 +10581,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, /* This symbol is local, or marked to become local. */ BFD_ASSERT (r_type == R_ARM_ABS32 || r_type == R_ARM_ABS32_NOI || (globals->fdpic_p && !bfd_link_pic(info))); - if (globals->symbian_p) + if (globals->root.target_os == is_symbian) { asection *osec; @@ -15513,7 +15504,7 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_ARM_ABS12: /* VxWorks uses dynamic R_ARM_ABS12 relocations for ldr __GOTT_INDEX__ offsets. */ - if (!htab->vxworks_p) + if (htab->root.target_os != is_vxworks) { may_need_local_target_p = TRUE; break; @@ -15666,7 +15657,7 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, return FALSE; /* BPABI objects never have dynamic relocations mapped. */ - if (htab->symbian_p) + if (htab->root.target_os == is_symbian) { flagword flags; @@ -16270,7 +16261,7 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) /* VxWorks executables have a second set of relocations for each PLT entry. They go in a separate relocation section, which is processed by the kernel loader. */ - if (htab->vxworks_p && !bfd_link_pic (info)) + if (htab->root.target_os == is_vxworks && !bfd_link_pic (info)) { /* There is a relocation for the initial PLT entry: an R_ARM_32 relocation for _GLOBAL_OFFSET_TABLE_. */ @@ -16314,7 +16305,7 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) return FALSE; } - if (!htab->symbian_p) + if (htab->root.target_os != is_symbian) { s = htab->root.sgot; h->got.offset = s->size; @@ -16575,7 +16566,7 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) } } - if (htab->vxworks_p) + if (htab->root.target_os == is_vxworks) { struct elf_dyn_relocs **pp; @@ -16729,7 +16720,6 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, bfd_size_type locsymcount; Elf_Internal_Shdr *symtab_hdr; asection *srel; - bfd_boolean is_vxworks = htab->vxworks_p; unsigned int symndx; struct fdpic_local *local_fdpic_cnts; @@ -16751,7 +16741,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, linker script /DISCARD/, so we'll be discarding the relocs too. */ } - else if (is_vxworks + else if (htab->root.target_os == is_vxworks && strcmp (p->sec->output_section->name, ".tls_vars") == 0) { @@ -17122,7 +17112,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, if (!add_dynamic_entry (DT_TEXTREL, 0)) return FALSE; } - if (htab->vxworks_p + if (htab->root.target_os == is_vxworks && !elf_vxworks_add_dynamic_entries (output_bfd, info)) return FALSE; } @@ -17267,7 +17257,9 @@ elf32_arm_finish_dynamic_symbol (bfd * output_bfd, and for FDPIC, the _GLOBAL_OFFSET_TABLE_ symbol is not absolute: it is relative to the ".got" section. */ if (h == htab->root.hdynamic - || (!htab->fdpic_p && !htab->vxworks_p && h == htab->root.hgot)) + || (!htab->fdpic_p + && htab->root.target_os != is_vxworks + && h == htab->root.hgot)) sym->st_shndx = SHN_ABS; return TRUE; @@ -17353,7 +17345,7 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info splt = htab->root.splt; BFD_ASSERT (splt != NULL && sdyn != NULL); - BFD_ASSERT (htab->symbian_p || sgot != NULL); + BFD_ASSERT (htab->root.target_os == is_symbian || sgot != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); @@ -17371,7 +17363,7 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info unsigned int type; 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; @@ -17396,7 +17388,8 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info goto get_vma_if_bpabi; case DT_PLTGOT: - name = htab->symbian_p ? ".got" : ".got.plt"; + name = (htab->root.target_os == is_symbian + ? ".got" : ".got.plt"); goto get_vma; case DT_JMPREL: name = RELOC_SECTION (htab, ".plt"); @@ -17409,7 +17402,7 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info bfd_set_error (bfd_error_invalid_operation); return FALSE; } - if (!htab->symbian_p) + if (htab->root.target_os != is_symbian) dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; else /* In the BPABI, tags in the PT_DYNAMIC section point @@ -17420,7 +17413,7 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info break; get_vma_if_bpabi: - if (htab->symbian_p) + if (htab->root.target_os == is_symbian) goto get_vma; break; @@ -17442,7 +17435,7 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info relocation section, since relocation sections are never allocated under the BPABI. PLT relocs are also included. */ - if (htab->symbian_p) + if (htab->root.target_os == is_symbian) { unsigned int i; type = ((dyn.d_tag == DT_REL || dyn.d_tag == DT_RELSZ) @@ -17518,7 +17511,7 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info got_address = sgot->output_section->vma + sgot->output_offset; plt_address = splt->output_section->vma + splt->output_offset; - if (htab->vxworks_p) + if (htab->root.target_os == is_vxworks) { /* The VxWorks GOT is relocated by the dynamic linker. Therefore, we must emit relocations rather than simply @@ -17541,7 +17534,7 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info SWAP_RELOC_OUT (htab) (output_bfd, &rel, htab->srelplt2->contents); } - else if (htab->nacl_p) + else if (htab->root.target_os == is_nacl) arm_nacl_put_plt0 (htab, output_bfd, splt, got_address + 8 - (plt_address + 16)); else if (using_thumb_only (htab)) @@ -17622,7 +17615,7 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info #endif } - if (htab->vxworks_p + if (htab->root.target_os == is_vxworks && !bfd_link_pic (info) && htab->root.splt->size > 0) { @@ -17652,7 +17645,9 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info } } - if (htab->nacl_p && htab->root.iplt != NULL && htab->root.iplt->size > 0) + if (htab->root.target_os == is_nacl + && htab->root.iplt != NULL + && htab->root.iplt->size > 0) /* NaCl uses a special first entry in .iplt too. */ arm_nacl_put_plt0 (htab, output_bfd, htab->root.iplt, 0); @@ -17929,14 +17924,14 @@ elf32_arm_output_plt_map_1 (output_arch_syminfo *osi, (osi->info->output_bfd, osi->sec->output_section)); addr = root_plt->offset & -2; - if (htab->symbian_p) + if (htab->root.target_os == is_symbian) { if (!elf32_arm_output_map_sym (osi, ARM_MAP_ARM, addr)) return FALSE; if (!elf32_arm_output_map_sym (osi, ARM_MAP_DATA, addr + 4)) return FALSE; } - else if (htab->vxworks_p) + else if (htab->root.target_os == is_vxworks) { if (!elf32_arm_output_map_sym (osi, ARM_MAP_ARM, addr)) return FALSE; @@ -17947,7 +17942,7 @@ elf32_arm_output_plt_map_1 (output_arch_syminfo *osi, if (!elf32_arm_output_map_sym (osi, ARM_MAP_DATA, addr + 20)) return FALSE; } - else if (htab->nacl_p) + else if (htab->root.target_os == is_nacl) { if (!elf32_arm_output_map_sym (osi, ARM_MAP_ARM, addr)) return FALSE; @@ -18309,7 +18304,7 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd, /* Output mapping symbols for the plt header. SymbianOS does not have a plt header. */ - if (htab->vxworks_p) + if (htab->root.target_os == is_vxworks) { /* VxWorks shared libraries have no PLT header. */ if (!bfd_link_pic (info)) @@ -18320,7 +18315,7 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd, return FALSE; } } - else if (htab->nacl_p) + else if (htab->root.target_os == is_nacl) { if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM, 0)) return FALSE; @@ -18334,7 +18329,7 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd, if (!elf32_arm_output_map_sym (&osi, ARM_MAP_THUMB, 16)) return FALSE; } - else if (!htab->symbian_p && !htab->fdpic_p) + else if (htab->root.target_os != is_symbian && !htab->fdpic_p) { if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM, 0)) return FALSE; @@ -18344,7 +18339,9 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd, #endif } } - if (htab->nacl_p && htab->root.iplt && htab->root.iplt->size > 0) + if (htab->root.target_os == is_nacl + && htab->root.iplt + && htab->root.iplt->size > 0) { /* NaCl uses a special first entry in .iplt too. */ osi.sec = htab->root.iplt; @@ -19916,7 +19913,7 @@ elf32_arm_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, if (elf32_arm_hash_table (info) == NULL) return FALSE; - if (elf32_arm_hash_table (info)->vxworks_p + if (elf32_arm_hash_table (info)->root.target_os == is_vxworks && !elf_vxworks_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)) return FALSE; @@ -20428,8 +20425,6 @@ elf32_arm_nacl_link_hash_table_create (bfd *abfd) struct elf32_arm_link_hash_table *htab = (struct elf32_arm_link_hash_table *) ret; - htab->nacl_p = 1; - htab->plt_header_size = 4 * ARRAY_SIZE (elf32_arm_nacl_plt0_entry); htab->plt_entry_size = 4 * ARRAY_SIZE (elf32_arm_nacl_plt_entry); } @@ -20484,6 +20479,8 @@ elf32_arm_nacl_plt_sym_val (bfd_vma i, const asection *plt, #undef ELF_MINPAGESIZE #undef ELF_COMMONPAGESIZE +#undef ELF_TARGET_OS +#define ELF_TARGET_OS is_nacl #include "elf32-target.h" @@ -20566,6 +20563,8 @@ elf32_arm_fdpic_omit_section_dynsym (bfd *output_bfd ATTRIBUTE_UNUSED, #undef elf_backend_omit_section_dynsym #define elf_backend_omit_section_dynsym elf32_arm_fdpic_omit_section_dynsym +#undef ELF_TARGET_OS + #include "elf32-target.h" #undef elf_match_priority @@ -20597,7 +20596,6 @@ elf32_arm_vxworks_link_hash_table_create (bfd *abfd) struct elf32_arm_link_hash_table *htab = (struct elf32_arm_link_hash_table *) ret; htab->use_rel = 0; - htab->vxworks_p = 1; } return ret; } @@ -20629,6 +20627,8 @@ elf32_arm_vxworks_final_write_processing (bfd *abfd) #define elf_backend_want_plt_sym 1 #undef ELF_MAXPAGESIZE #define ELF_MAXPAGESIZE 0x1000 +#undef ELF_TARGET_OS +#define ELF_TARGET_OS is_vxworks #include "elf32-target.h" @@ -20885,7 +20885,6 @@ elf32_arm_symbian_link_hash_table_create (bfd *abfd) htab->plt_header_size = 0; /* The PLT entries are each one instruction and one word. */ htab->plt_entry_size = 4 * ARRAY_SIZE (elf32_arm_symbian_plt_entry); - htab->symbian_p = 1; /* Symbian uses armv5t or above, so use_blx is always true. */ htab->use_blx = 1; htab->root.is_relocatable_executable = 1; @@ -21016,5 +21015,7 @@ elf32_arm_symbian_plt_sym_val (bfd_vma i, const asection *plt, #define elf_backend_dtrel_excludes_plt 0 #undef ELF_MAXPAGESIZE #define ELF_MAXPAGESIZE 0x8000 +#undef ELF_TARGET_OS +#define ELF_TARGET_OS is_symbian #include "elf32-target.h" diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index f6f6699..6f4f7f4 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 diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index e3c4f55..a585e42 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -2670,6 +2670,9 @@ mips_vxworks_final_write_processing (bfd *abfd) #define ELF_MAXPAGESIZE 0x1000 #define ELF_COMMONPAGESIZE 0x1000 +#undef ELF_TARGET_OS +#define ELF_TARGET_OS is_vxworks + #undef elf_backend_want_got_plt #define elf_backend_want_got_plt 1 #undef elf_backend_want_plt_sym 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; 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 */ diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c index 27fc158..4be618c 100644 --- a/bfd/elf32-sparc.c +++ b/bfd/elf32-sparc.c @@ -309,25 +309,6 @@ elf32_sparc_copy_solaris_special_section_fields (const bfd *ibfd ATTRIBUTE_UNUSE #include "elf32-target.h" -/* A wrapper around _bfd_sparc_elf_link_hash_table_create that identifies - the target system as VxWorks. */ - -static struct bfd_link_hash_table * -elf32_sparc_vxworks_link_hash_table_create (bfd *abfd) -{ - struct bfd_link_hash_table *ret; - - ret = _bfd_sparc_elf_link_hash_table_create (abfd); - if (ret) - { - struct _bfd_sparc_elf_link_hash_table *htab; - - htab = (struct _bfd_sparc_elf_link_hash_table *) ret; - htab->is_vxworks = 1; - } - return ret; -} - /* A final_write_processing hook that does both the SPARC- and VxWorks- specific handling. */ @@ -346,9 +327,8 @@ elf32_sparc_vxworks_final_write_processing (bfd *abfd) #undef ELF_MINPAGESIZE #define ELF_MINPAGESIZE 0x1000 -#undef bfd_elf32_bfd_link_hash_table_create -#define bfd_elf32_bfd_link_hash_table_create \ - elf32_sparc_vxworks_link_hash_table_create +#undef ELF_TARGET_OS +#define ELF_TARGET_OS is_vxworks #undef elf_backend_want_got_plt #define elf_backend_want_got_plt 1 diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index eada0e5..6e6c3c3 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -985,12 +985,6 @@ static const struct elf_x86_non_lazy_plt_layout elf_x32_non_lazy_ibt_plt = sizeof (elf_x86_64_eh_frame_non_lazy_plt) /* eh_frame_plt_size */ }; -static const struct elf_x86_backend_data elf_x86_64_arch_bed = - { - is_normal /* os */ - }; - -#define elf_backend_arch_data &elf_x86_64_arch_bed static bfd_boolean elf64_x86_64_elf_object_p (bfd *abfd) @@ -4797,7 +4791,7 @@ elf_x86_64_get_synthetic_symtab (bfd *abfd, if (relsize <= 0) return -1; - if (get_elf_x86_backend_data (abfd)->target_os != is_nacl) + if (get_elf_backend_data (abfd)->target_os != is_nacl) { lazy_plt = &elf_x86_64_lazy_plt; non_lazy_plt = &elf_x86_64_non_lazy_plt; @@ -5148,7 +5142,7 @@ elf_x86_64_link_setup_gnu_properties (struct bfd_link_info *info) /* This is unused for x86-64. */ init_table.plt0_pad_byte = 0x90; - if (get_elf_x86_backend_data (info->output_bfd)->target_os != is_nacl) + if (get_elf_backend_data (info->output_bfd)->target_os != is_nacl) { const struct elf_backend_data *bed = get_elf_backend_data (info->output_bfd); @@ -5329,13 +5323,8 @@ elf_x86_64_special_sections[]= #undef TARGET_LITTLE_NAME #define TARGET_LITTLE_NAME "elf64-x86-64-sol2" -static const struct elf_x86_backend_data elf_x86_64_solaris_arch_bed = - { - is_solaris /* os */ - }; - -#undef elf_backend_arch_data -#define elf_backend_arch_data &elf_x86_64_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. */ @@ -5465,7 +5454,7 @@ static const bfd_byte elf_x86_64_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 */ @@ -5525,13 +5514,8 @@ static const struct elf_x86_lazy_plt_layout elf_x86_64_nacl_plt = sizeof (elf_x86_64_nacl_eh_frame_plt) /* eh_frame_plt_size */ }; -static const struct elf_x86_backend_data elf_x86_64_nacl_arch_bed = - { - is_nacl /* os */ - }; - -#undef elf_backend_arch_data -#define elf_backend_arch_data &elf_x86_64_nacl_arch_bed +#undef ELF_TARGET_OS +#define ELF_TARGET_OS is_nacl #undef elf_backend_object_p #define elf_backend_object_p elf64_x86_64_nacl_elf_object_p @@ -5635,8 +5619,7 @@ elf64_l1om_elf_object_p (bfd *abfd) #define ELF_COMMONPAGESIZE 0x1000 #undef elf_backend_plt_alignment #define elf_backend_plt_alignment 4 -#undef elf_backend_arch_data -#define elf_backend_arch_data &elf_x86_64_arch_bed +#undef ELF_TARGET_OS #include "elf64-target.h" diff --git a/bfd/elflink.c b/bfd/elflink.c index 7e86ade..60a3c22 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -7804,6 +7804,7 @@ _bfd_elf_link_hash_table_init table->root.type = bfd_link_elf_hash_table; table->hash_table_id = target_id; + table->target_os = get_elf_backend_data (abfd)->target_os; return ret; } diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 6c7aaa3..160febe 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -462,9 +462,6 @@ struct mips_elf_link_hash_table /* True if we are targetting R6 compact branches. */ bfd_boolean compact_branches; - /* True if we're generating code for VxWorks. */ - bfd_boolean is_vxworks; - /* True if we already reported the small-data section overflow. */ bfd_boolean small_data_overflow_reported; @@ -904,7 +901,8 @@ static bfd *reldyn_sorting_bfd; /* The name of the dynamic relocation section. */ #define MIPS_ELF_REL_DYN_NAME(INFO) \ - (mips_elf_hash_table (INFO)->is_vxworks ? ".rela.dyn" : ".rel.dyn") + (mips_elf_hash_table (INFO)->root.target_os == is_vxworks \ + ? ".rela.dyn" : ".rel.dyn") /* In case we're on a 32-bit machine, construct a 64-bit "-1" value from smaller values. Start with zero, widen, *then* decrement. */ @@ -919,7 +917,8 @@ static bfd *reldyn_sorting_bfd; /* The offset of $gp from the beginning of the .got section. */ #define ELF_MIPS_GP_OFFSET(INFO) \ - (mips_elf_hash_table (INFO)->is_vxworks ? 0x0 : 0x7ff0) + (mips_elf_hash_table (INFO)->root.target_os == is_vxworks \ + ? 0x0 : 0x7ff0) /* The maximum size of the GOT for it to be addressable using 16-bit offsets from $gp. */ @@ -3821,7 +3820,7 @@ mips_elf_create_local_got_entry (bfd *abfd, struct bfd_link_info *info, MIPS_ELF_PUT_WORD (abfd, value, htab->root.sgot->contents + entry->gotidx); /* These GOT entries need a dynamic relocation on VxWorks. */ - if (htab->is_vxworks) + if (htab->root.target_os == is_vxworks) { Elf_Internal_Rela outrel; asection *s; @@ -4166,7 +4165,7 @@ mips_elf_allocate_dynamic_relocations (bfd *abfd, struct bfd_link_info *info, s = mips_elf_rel_dyn_section (info, FALSE); BFD_ASSERT (s != NULL); - if (htab->is_vxworks) + if (htab->root.target_os == is_vxworks) s->size += n * MIPS_ELF_RELA_SIZE (abfd); else { @@ -4552,7 +4551,7 @@ mips_elf_count_got_symbols (struct mips_elf_link_hash_entry *h, void *data) entry if it was only used for relocations; those relocations will be against the null or section symbol instead of H. */ h->global_got_area = GGA_NONE; - else if (htab->is_vxworks + else if (htab->root.target_os == is_vxworks && h->got_only_for_calls && h->root.plt.plist->mips_offset != MINUS_ONE) /* On VxWorks, calls can refer directly to the .got.plt entry; @@ -5266,7 +5265,7 @@ mips_elf_create_got_section (bfd *abfd, struct bfd_link_info *info) static bfd_boolean is_gott_symbol (struct bfd_link_info *info, struct elf_link_hash_entry *h) { - return (mips_elf_hash_table (info)->is_vxworks + return (mips_elf_hash_table (info)->root.target_os == is_vxworks && bfd_link_pic (info) && (strcmp (h->root.root.string, "__GOTT_BASE__") == 0 || strcmp (h->root.root.string, "__GOTT_INDEX__") == 0)); @@ -5904,7 +5903,7 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, { /* On VxWorks, CALL relocations should refer to the .got.plt entry, which is initialized to point at the PLT stub. */ - if (htab->is_vxworks + if (htab->root.target_os == is_vxworks && (call_hi16_reloc_p (r_type) || call_lo16_reloc_p (r_type) || call16_reloc_p (r_type))) @@ -5924,7 +5923,7 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, MIPS_ELF_PUT_WORD (dynobj, symbol, htab->root.sgot->contents + g); } } - else if (!htab->is_vxworks + else if (htab->root.target_os != is_vxworks && (call16_reloc_p (r_type) || got16_reloc_p (r_type))) /* The calculation below does not involve "g". */ break; @@ -6206,7 +6205,7 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, case R_MICROMIPS_CALL16: /* VxWorks does not have separate local and global semantics for R_MIPS*_GOT16; every relocation evaluates to "G". */ - if (!htab->is_vxworks && local_p) + if (htab->root.target_os != is_vxworks && local_p) { value = mips_elf_got16_entry (abfd, input_bfd, info, symbol + addend, !was_local_p); @@ -6745,7 +6744,8 @@ mips_elf_create_dynamic_relocation (bfd *output_bfd, in the relocation. */ if (h != NULL && ! SYMBOL_REFERENCES_LOCAL (info, &h->root)) { - BFD_ASSERT (htab->is_vxworks || h->global_got_area != GGA_NONE); + BFD_ASSERT (htab->root.target_os == is_vxworks + || h->global_got_area != GGA_NONE); indx = h->root.dynindx; if (SGI_COMPAT (output_bfd)) defined_p = h->root.def_regular; @@ -6804,7 +6804,7 @@ mips_elf_create_dynamic_relocation (bfd *output_bfd, if (defined_p && r_type != R_MIPS_REL32) *addendp += symbol; - if (htab->is_vxworks) + if (htab->root.target_os == is_vxworks) /* VxWorks uses non-relative relocations for this. */ outrel[0].r_info = ELF32_R_INFO (indx, R_MIPS_32); else @@ -6850,7 +6850,7 @@ mips_elf_create_dynamic_relocation (bfd *output_bfd, (sreloc->contents + sreloc->reloc_count * sizeof (Elf64_Mips_External_Rel))); } - else if (htab->is_vxworks) + else if (htab->root.target_os == is_vxworks) { /* VxWorks uses RELA rather than REL dynamic relocations. */ outrel[0].r_addend = *addendp; @@ -7973,7 +7973,7 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) /* The psABI requires a read-only .dynamic section, but the VxWorks EABI doesn't. */ - if (!htab->is_vxworks) + if (htab->root.target_os != is_vxworks) { s = bfd_get_linker_section (abfd, ".dynamic"); if (s != NULL) @@ -8121,7 +8121,7 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) return FALSE; /* Do the usual VxWorks handling. */ - if (htab->is_vxworks + if (htab->root.target_os == is_vxworks && !elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2)) return FALSE; @@ -8723,7 +8723,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, elf_hash_table (info)->dynobj = dynobj = abfd; if (!mips_elf_create_got_section (dynobj, info)) return FALSE; - if (htab->is_vxworks && !bfd_link_pic (info)) + if (htab->root.target_os == is_vxworks + && !bfd_link_pic (info)) { _bfd_error_handler /* xgettext:c-format */ @@ -8769,7 +8770,7 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, against a read-only section. */ if ((bfd_link_pic (info) || (h != NULL - && !htab->is_vxworks + && htab->root.target_os != is_vxworks && strcmp (h->root.root.string, "__gnu_local_gp") != 0 && !(!info->nocopyreloc && !PIC_OBJECT_P (abfd) @@ -8811,7 +8812,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, relocations related to taking the function's address. This doesn't apply to VxWorks, where CALL relocs refer to a .got.plt entry instead of a normal .got entry. */ - if (!htab->is_vxworks && (!can_make_dynamic_p || !call_reloc_p)) + if (htab->root.target_os != is_vxworks + && (!can_make_dynamic_p || !call_reloc_p)) ((struct mips_elf_link_hash_entry *) h)->no_fn_stub = TRUE; } @@ -8836,7 +8838,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, else if (call_lo16_reloc_p (r_type) || got_lo16_reloc_p (r_type) || got_disp_reloc_p (r_type) - || (got16_reloc_p (r_type) && htab->is_vxworks)) + || (got16_reloc_p (r_type) + && htab->root.target_os == is_vxworks)) { /* We may need a local GOT entry for this relocation. We don't count R_MIPS_GOT_PAGE because we can estimate the @@ -9200,7 +9203,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* VxWorks executables are handled elsewhere; we only need to allocate relocations in shared objects. */ - if (htab->is_vxworks && !bfd_link_pic (info)) + if (htab->root.target_os == is_vxworks && !bfd_link_pic (info)) return TRUE; /* Ignore indirect symbols. All relocations against such symbols @@ -9245,7 +9248,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) VxWorks does not enforce the same mapping between the GOT and the symbol table, so the same requirement does not apply there. */ - if (!htab->is_vxworks) + if (htab->root.target_os != is_vxworks) { if (hmips->global_got_area > GGA_RELOC_ONLY) hmips->global_got_area = GGA_RELOC_ONLY; @@ -9312,7 +9315,9 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info, Traditional stubs are only available on SVR4 psABI-based systems; VxWorks always uses PLTs instead. */ - if (!htab->is_vxworks && h->needs_plt && !hmips->no_fn_stub) + if (htab->root.target_os != is_vxworks + && h->needs_plt + && !hmips->no_fn_stub) { if (! elf_hash_table (info)->dynamic_sections_created) return TRUE; @@ -9361,7 +9366,7 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info, entry is 16 bytes and the PLT0 entry is 32 bytes. Encourage better cache usage by aligning. We do this lazily to avoid pessimizing traditional objects. */ - if (!htab->is_vxworks + if (htab->root.target_os != is_vxworks && !bfd_set_section_alignment (htab->root.splt, 5)) return FALSE; @@ -9373,21 +9378,23 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* On non-VxWorks targets, the first two entries in .got.plt are reserved. */ - if (!htab->is_vxworks) + if (htab->root.target_os != is_vxworks) htab->plt_got_index += (get_elf_backend_data (dynobj)->got_header_size / MIPS_ELF_GOT_SIZE (dynobj)); /* On VxWorks, also allocate room for the header's .rela.plt.unloaded entries. */ - if (htab->is_vxworks && !bfd_link_pic (info)) + if (htab->root.target_os == is_vxworks + && !bfd_link_pic (info)) htab->srelplt2->size += 2 * sizeof (Elf32_External_Rela); /* Now work out the sizes of individual PLT entries. */ - if (htab->is_vxworks && bfd_link_pic (info)) + if (htab->root.target_os == is_vxworks + && bfd_link_pic (info)) htab->plt_mips_entry_size = 4 * ARRAY_SIZE (mips_vxworks_shared_plt_entry); - else if (htab->is_vxworks) + else if (htab->root.target_os == is_vxworks) htab->plt_mips_entry_size = 4 * ARRAY_SIZE (mips_vxworks_exec_plt_entry); else if (newabi_p) @@ -9430,7 +9437,7 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info, standard entry actually has to be used as the stub ends with a J instruction. */ if (newabi_p - || htab->is_vxworks + || htab->root.target_os == is_vxworks || hmips->call_stub || hmips->call_fp_stub) { @@ -9472,12 +9479,12 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info, hmips->use_plt_entry = TRUE; /* Make room for the R_MIPS_JUMP_SLOT relocation. */ - htab->root.srelplt->size += (htab->is_vxworks + htab->root.srelplt->size += (htab->root.target_os == is_vxworks ? MIPS_ELF_RELA_SIZE (dynobj) : MIPS_ELF_REL_SIZE (dynobj)); /* Make room for the .rela.plt.unloaded relocations. */ - if (htab->is_vxworks && !bfd_link_pic (info)) + if (htab->root.target_os == is_vxworks && !bfd_link_pic (info)) htab->srelplt2->size += 3 * sizeof (Elf32_External_Rela); /* All relocations against this symbol that could have been made @@ -9542,7 +9549,7 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info, } if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) { - if (htab->is_vxworks) + if (htab->root.target_os == is_vxworks) srel->size += sizeof (Elf32_External_Rela); else mips_elf_allocate_dynamic_relocations (dynobj, info, 1); @@ -9625,7 +9632,7 @@ mips_elf_lay_out_got (bfd *output_bfd, struct bfd_link_info *info) /* Allocate room for the reserved entries. VxWorks always reserves 3 entries; other objects only reserve 2 entries. */ BFD_ASSERT (g->assigned_low_gotno == 0); - if (htab->is_vxworks) + if (htab->root.target_os == is_vxworks) htab->reserved_gotno = 3; else htab->reserved_gotno = 2; @@ -9657,7 +9664,7 @@ mips_elf_lay_out_got (bfd *output_bfd, struct bfd_link_info *info) } } - if (htab->is_vxworks) + if (htab->root.target_os == is_vxworks) /* There's no need to allocate page entries for VxWorks; R_MIPS*_GOT16 relocations against local symbols evaluate to "G", and the EABI does not include R_MIPS_GOT_PAGE. */ @@ -9682,7 +9689,8 @@ mips_elf_lay_out_got (bfd *output_bfd, struct bfd_link_info *info) /* VxWorks does not support multiple GOTs. It initializes $gp to __GOTT_BASE__[__GOTT_INDEX__], the value of which is set by the dynamic loader. */ - if (!htab->is_vxworks && s->size > MIPS_ELF_GOT_MAX_SIZE (info)) + if (htab->root.target_os != is_vxworks + && s->size > MIPS_ELF_GOT_MAX_SIZE (info)) { if (!mips_elf_multi_got (output_bfd, info, s, page_gotno)) return FALSE; @@ -9708,7 +9716,7 @@ mips_elf_lay_out_got (bfd *output_bfd, struct bfd_link_info *info) == g->global_gotno + g->local_gotno + g->tls_gotno); /* Each VxWorks GOT entry needs an explicit relocation. */ - if (htab->is_vxworks && bfd_link_pic (info)) + if (htab->root.target_os == is_vxworks && bfd_link_pic (info)) g->relocs += g->global_gotno + g->local_gotno - htab->reserved_gotno; /* Allocate room for the TLS relocations. */ @@ -9890,7 +9898,7 @@ mips_elf_set_plt_sym_value (struct mips_elf_link_hash_entry *h, void *data) /* For VxWorks, point at the PLT load stub rather than the lazy resolution stub; this stub will become the canonical function address. */ - if (htab->is_vxworks) + if (htab->root.target_os == is_vxworks) val += 8; h->root.root.u.def.section = htab->root.splt; @@ -9955,9 +9963,9 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, BFD_ASSERT (htab->root.sgotplt->size == 0); BFD_ASSERT (htab->root.splt->size == 0); - if (htab->is_vxworks && bfd_link_pic (info)) + if (htab->root.target_os == is_vxworks && bfd_link_pic (info)) size = 4 * ARRAY_SIZE (mips_vxworks_shared_plt0_entry); - else if (htab->is_vxworks) + else if (htab->root.target_os == is_vxworks) size = 4 * ARRAY_SIZE (mips_vxworks_exec_plt0_entry); else if (ABI_64_P (output_bfd)) size = 4 * ARRAY_SIZE (mips_n64_exec_plt0_entry); @@ -10073,7 +10081,8 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, room for an extra nop to fill the delay slot. This is for CPUs without load interlocking. */ if (! LOAD_INTERLOCKS_P (output_bfd) - && ! htab->is_vxworks && s->size > 0) + && htab->root.target_os != is_vxworks + && s->size > 0) s->size += 4; } else if (! CONST_STRNEQ (name, ".init") @@ -10131,7 +10140,9 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0)) return FALSE; - if (reltext && (SGI_COMPAT (output_bfd) || htab->is_vxworks)) + if (reltext + && (SGI_COMPAT (output_bfd) + || htab->root.target_os == is_vxworks)) info->flags |= DF_TEXTREL; if ((info->flags & DF_TEXTREL) != 0) @@ -10150,7 +10161,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, return FALSE; sreldyn = mips_elf_rel_dyn_section (info, FALSE); - if (htab->is_vxworks) + if (htab->root.target_os == is_vxworks) { /* VxWorks uses .rela.dyn instead of .rel.dyn. It does not use any of the DT_MIPS_* tags. */ @@ -10230,7 +10241,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_PLTGOT, 0)) return FALSE; } - if (htab->is_vxworks + if (htab->root.target_os == is_vxworks && !elf_vxworks_add_dynamic_entries (output_bfd, info)) return FALSE; } @@ -10872,7 +10883,7 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd, dynobj = elf_hash_table (info)->dynobj; hmips = (struct mips_elf_link_hash_entry *) h; - BFD_ASSERT (!htab->is_vxworks); + BFD_ASSERT (htab->root.target_os != is_vxworks); if (h->plt.plist != NULL && (h->plt.plist->mips_offset != MINUS_ONE @@ -11808,7 +11819,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, break; case DT_RELAENT: - BFD_ASSERT (htab->is_vxworks); + BFD_ASSERT (htab->root.target_os == is_vxworks); dyn.d_un.d_val = MIPS_ELF_RELA_SIZE (dynobj); break; @@ -11947,7 +11958,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, case DT_PLTREL: BFD_ASSERT (htab->use_plts_and_copy_relocs); - if (htab->is_vxworks) + if (htab->root.target_os == is_vxworks) dyn.d_un.d_val = DT_RELA; else dyn.d_un.d_val = DT_REL; @@ -11991,7 +12002,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, default: swap_out_p = FALSE; - if (htab->is_vxworks + if (htab->root.target_os == is_vxworks && elf_vxworks_finish_dynamic_entry (output_bfd, &dyn)) swap_out_p = TRUE; break; @@ -12016,7 +12027,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, if (sgot != NULL && sgot->size > 0 && !bfd_is_abs_section (sgot->output_section)) { - if (htab->is_vxworks) + if (htab->root.target_os == is_vxworks) { /* The first entry of the global offset table points to the ".dynamic" section. The second is initialized by the @@ -12179,7 +12190,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, increasing order of r_symndx. The VxWorks EABI doesn't require this, and because the code below handles REL rather than RELA relocations, using it for VxWorks would be outright harmful. */ - if (!htab->is_vxworks) + if (htab->root.target_os != is_vxworks) { s = mips_elf_rel_dyn_section (info, FALSE); if (s != NULL @@ -12201,7 +12212,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, if (htab->root.splt && htab->root.splt->size > 0) { - if (htab->is_vxworks) + if (htab->root.target_os == is_vxworks) { if (bfd_link_pic (info)) mips_vxworks_finish_shared_plt (output_bfd, info); @@ -14303,7 +14314,6 @@ _bfd_mips_vxworks_link_hash_table_create (bfd *abfd) htab = (struct mips_elf_link_hash_table *) ret; htab->use_plts_and_copy_relocs = TRUE; - htab->is_vxworks = TRUE; } return ret; } @@ -14682,7 +14692,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info) elf_gp (abfd) = (h->u.def.value + h->u.def.section->output_section->vma + h->u.def.section->output_offset); - else if (htab->is_vxworks + else if (htab->root.target_os == is_vxworks && (h = bfd_link_hash_lookup (info->hash, "_GLOBAL_OFFSET_TABLE_", FALSE, FALSE, TRUE)) @@ -16637,7 +16647,9 @@ _bfd_mips_init_file_header (bfd *abfd, struct bfd_link_info *link_info) BFD_ASSERT (htab != NULL); } - if (htab != NULL && htab->use_plts_and_copy_relocs && !htab->is_vxworks) + if (htab != NULL + && htab->use_plts_and_copy_relocs + && htab->root.target_os != is_vxworks) i_ehdrp->e_ident[EI_ABIVERSION] = MIPS_LIBC_ABI_MIPS_PLT; if (mips_elf_tdata (abfd)->abiflags.fp_abi == Val_GNU_MIPS_ABI_FP_64 diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c index 5ef29ea..eca44c9 100644 --- a/bfd/elfxx-sparc.c +++ b/bfd/elfxx-sparc.c @@ -1216,7 +1216,7 @@ _bfd_sparc_elf_create_dynamic_sections (bfd *dynobj, if (!_bfd_elf_create_dynamic_sections (dynobj, info)) return FALSE; - if (htab->is_vxworks) + if (htab->elf.target_os == is_vxworks) { if (!elf_vxworks_create_dynamic_sections (dynobj, info, &htab->srelplt2)) return FALSE; @@ -2076,7 +2076,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) s->size = htab->plt_header_size; /* Allocate space for the .rela.plt.unloaded relocations. */ - if (htab->is_vxworks && !bfd_link_pic (info)) + if (htab->elf.target_os == is_vxworks + && !bfd_link_pic (info)) htab->srelplt2->size = sizeof (Elf32_External_Rela) * 2; } @@ -2128,7 +2129,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) htab->elf.irelplt->size += SPARC_ELF_RELA_BYTES (htab); } - if (htab->is_vxworks) + if (htab->elf.target_os == is_vxworks) { /* Allocate space for the .got.plt entry. */ htab->elf.sgotplt->size += 4; @@ -2231,7 +2232,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; @@ -2433,7 +2434,7 @@ _bfd_sparc_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) { @@ -2503,7 +2504,7 @@ _bfd_sparc_elf_size_dynamic_sections (bfd *output_bfd, htab_traverse (htab->loc_hash_table, allocate_local_dynrelocs, info); if (! ABI_64_P (output_bfd) - && !htab->is_vxworks + && htab->elf.target_os != is_vxworks && elf_hash_table (info)->dynamic_sections_created) { /* Make space for the trailing nop in .plt. */ @@ -2829,7 +2830,8 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, sreloc = elf_section_data (input_section)->sreloc; /* 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")); @@ -4272,7 +4274,7 @@ _bfd_sparc_elf_finish_dynamic_symbol (bfd *output_bfd, abort (); /* Fill in the entry in the .rela.plt section. */ - if (htab->is_vxworks) + if (htab->elf.target_os == is_vxworks) { /* Work out the index of this PLT entry. */ rela_index = ((h->plt.offset - htab->plt_header_size) @@ -4474,7 +4476,7 @@ _bfd_sparc_elf_finish_dynamic_symbol (bfd *output_bfd, ".got" section. Likewise _PROCEDURE_LINKAGE_TABLE_ and ".plt". */ if (sym != NULL && (h == htab->elf.hdynamic - || (!htab->is_vxworks + || (htab->elf.target_os != is_vxworks && (h == htab->elf.hgot || h == htab->elf.hplt)))) sym->st_shndx = SHN_ABS; @@ -4508,7 +4510,7 @@ sparc_finish_dyn (bfd *output_bfd, struct bfd_link_info *info, bed->s->swap_dyn_in (dynobj, dyncon, &dyn); - if (htab->is_vxworks && dyn.d_tag == DT_PLTGOT) + if (htab->elf.target_os == is_vxworks && dyn.d_tag == DT_PLTGOT) { /* On VxWorks, DT_PLTGOT should point to the start of the GOT, not to the start of the PLT. */ @@ -4519,7 +4521,7 @@ sparc_finish_dyn (bfd *output_bfd, struct bfd_link_info *info, bed->s->swap_dyn_out (output_bfd, &dyn, dyncon); } } - else if (htab->is_vxworks + else if (htab->elf.target_os == is_vxworks && elf_vxworks_finish_dynamic_entry (output_bfd, &dyn)) bed->s->swap_dyn_out (output_bfd, &dyn, dyncon); else if (abi_64_p && dyn.d_tag == DT_SPARC_REGISTER) @@ -4744,7 +4746,7 @@ _bfd_sparc_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *i /* Initialize the contents of the .plt section. */ if (splt->size > 0) { - if (htab->is_vxworks) + if (htab->elf.target_os == is_vxworks) { if (bfd_link_pic (info)) sparc_vxworks_finish_shared_plt (output_bfd, info); @@ -4762,7 +4764,8 @@ _bfd_sparc_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *i if (elf_section_data (splt->output_section) != NULL) elf_section_data (splt->output_section)->this_hdr.sh_entsize - = ((htab->is_vxworks || !ABI_64_P (output_bfd)) + = ((htab->elf.target_os == is_vxworks + || !ABI_64_P (output_bfd)) ? 0 : htab->plt_entry_size); } diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index b41fcde..c2b828b 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -362,6 +362,10 @@ #define ELF_TARGET_ID GENERIC_ELF_DATA #endif +#ifndef ELF_TARGET_OS +#define ELF_TARGET_OS is_normal +#endif + #ifndef ELF_OSABI #define ELF_OSABI ELFOSABI_NONE #endif @@ -799,6 +803,7 @@ static struct elf_backend_data elfNN_bed = { ELF_ARCH, /* arch */ ELF_TARGET_ID, /* target_id */ + ELF_TARGET_OS, /* target_os */ ELF_MACHINE_CODE, /* elf_machine_code */ ELF_OSABI, /* elf_osabi */ ELF_MAXPAGESIZE, /* maxpagesize */ diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index d796292..6b8e56d 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -260,7 +260,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) } } - if (htab->target_os == is_vxworks && !bfd_link_pic (info)) + if (htab->elf.target_os == is_vxworks && !bfd_link_pic (info)) { /* VxWorks has a second set of relocations for each PLT entry in executables. They go in a separate relocation section, @@ -407,7 +407,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) } } - if (htab->target_os == is_vxworks) + if (htab->elf.target_os == is_vxworks) { struct elf_dyn_relocs **pp; for (pp = &h->dyn_relocs; (p = *pp) != NULL; ) @@ -762,7 +762,6 @@ _bfd_x86_elf_link_hash_table_create (bfd *abfd) ret->tls_get_addr = "___tls_get_addr"; } } - ret->target_os = get_elf_x86_backend_data (abfd)->target_os; ret->loc_hash_table = htab_try_create (1024, _bfd_x86_elf_local_htab_hash, @@ -1045,7 +1044,7 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd, linker script /DISCARD/, so we'll be discarding the relocs too. */ } - else if (htab->target_os == is_vxworks + else if (htab->elf.target_os == is_vxworks && strcmp (p->sec->output_section->name, ".tls_vars") == 0) { @@ -1203,7 +1202,8 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd, htab->elf.sgotplt->size = 0; /* Solaris requires to keep _GLOBAL_OFFSET_TABLE_ even if it isn't used. */ - if (htab->elf.hgot != NULL && htab->target_os != is_solaris) + if (htab->elf.hgot != NULL + && htab->elf.target_os != is_solaris) { /* Remove the unused _GLOBAL_OFFSET_TABLE_ from symbol table. */ @@ -1430,7 +1430,7 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd, return FALSE; } } - if (htab->target_os == is_vxworks + if (htab->elf.target_os == is_vxworks && !elf_vxworks_add_dynamic_entries (output_bfd, info)) return FALSE; } @@ -1522,7 +1522,7 @@ _bfd_x86_elf_finish_dynamic_sections (bfd *output_bfd, switch (dyn.d_tag) { default: - if (htab->target_os == is_vxworks + if (htab->elf.target_os == is_vxworks && elf_vxworks_finish_dynamic_entry (output_bfd, &dyn)) break; continue; @@ -1987,7 +1987,7 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info, if (ELIMINATE_COPY_RELOCS && (bed->target_id == X86_64_ELF_DATA || (!eh->gotoff_ref - && htab->target_os != is_vxworks))) + && htab->elf.target_os != is_vxworks))) { /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy @@ -2762,7 +2762,7 @@ _bfd_x86_elf_link_setup_gnu_properties still be used with LD_AUDIT or LD_PROFILE if PLT entry is used for canonical function address. */ htab->plt.has_plt0 = 1; - normal_target = htab->target_os == is_normal; + normal_target = htab->elf.target_os == is_normal; if (normal_target) { @@ -2825,7 +2825,7 @@ _bfd_x86_elf_link_setup_gnu_properties htab->plt.eh_frame_plt = htab->lazy_plt->eh_frame_plt; } - if (htab->target_os == is_vxworks + if (htab->elf.target_os == is_vxworks && !elf_vxworks_create_dynamic_sections (dynobj, info, &htab->srelplt2)) { diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h index de4e78f..7cdc432 100644 --- a/bfd/elfxx-x86.h +++ b/bfd/elfxx-x86.h @@ -436,14 +436,6 @@ struct elf_x86_plt_layout #define elf_x86_hash_entry(ent) \ ((struct elf_x86_link_hash_entry *)(ent)) -enum elf_x86_target_os -{ - is_normal, - is_solaris, - is_vxworks, - is_nacl -}; - /* x86 ELF linker hash table. */ struct elf_x86_link_hash_table @@ -531,7 +523,6 @@ struct elf_x86_link_hash_table bfd_vma (*r_info) (bfd_vma, bfd_vma); bfd_vma (*r_sym) (bfd_vma); bfd_boolean (*is_reloc_section) (const char *); - enum elf_x86_target_os target_os; unsigned int sizeof_reloc; unsigned int dt_reloc; unsigned int dt_reloc_sz; @@ -546,18 +537,6 @@ struct elf_x86_link_hash_table struct elf_linker_x86_params *params; }; -/* Architecture-specific backend data for x86. */ - -struct elf_x86_backend_data -{ - /* Target system. */ - enum elf_x86_target_os target_os; -}; - -#define get_elf_x86_backend_data(abfd) \ - ((const struct elf_x86_backend_data *) \ - get_elf_backend_data (abfd)->arch_data) - struct elf_x86_init_table { /* The lazy PLT layout. */ |