+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
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
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;
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;
/* 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;
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))
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;
? (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);
}
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)
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. */
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. */
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,
+ 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;
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;
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. */
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. */
|| 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)
/* 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;
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;
return FALSE;
/* BPABI objects never have dynamic relocations mapped. */
- if (htab->symbian_p)
+ if (htab->root.target_os == is_symbian)
{
flagword flags;
/* 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_. */
return FALSE;
}
- if (!htab->symbian_p)
+ if (htab->root.target_os != is_symbian)
{
s = htab->root.sgot;
h->got.offset = s->size;
}
}
- if (htab->vxworks_p)
+ if (htab->root.target_os == is_vxworks)
{
struct elf_dyn_relocs **pp;
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;
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)
{
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;
}
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;
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);
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;
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");
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
break;
get_vma_if_bpabi:
- if (htab->symbian_p)
+ if (htab->root.target_os == is_symbian)
goto get_vma;
break;
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)
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
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))
#endif
}
- if (htab->vxworks_p
+ if (htab->root.target_os == is_vxworks
&& !bfd_link_pic (info)
&& htab->root.splt->size > 0)
{
}
}
- 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);
(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;
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;
/* 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))
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;
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;
#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;
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;
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);
}
#undef ELF_MINPAGESIZE
#undef ELF_COMMONPAGESIZE
+#undef ELF_TARGET_OS
+#define ELF_TARGET_OS is_nacl
#include "elf32-target.h"
#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
struct elf32_arm_link_hash_table *htab
= (struct elf32_arm_link_hash_table *) ret;
htab->use_rel = 0;
- htab->vxworks_p = 1;
}
return ret;
}
#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"
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;
#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"
#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. */
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"));
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;
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
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:
case is_nacl:
lazy_plt = &elf_i386_nacl_plt;
break;
+ default:
+ abort ();
}
got_addr = 0;
{
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:
init_table.lazy_ibt_plt = NULL;
init_table.non_lazy_ibt_plt = NULL;
break;
+ default:
+ abort ();
}
init_table.r_info = elf32_r_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. */
#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
|| 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 */
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)
{
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
#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
#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
/* 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;
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. */
return FALSE;
}
- if (htab->is_vxworks
+ if (htab->elf.target_os == is_vxworks
&& !elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2))
return FALSE;
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);
}
}
- if (!htab->is_vxworks
+ if (htab->elf.target_os != is_vxworks
&& is_branch_reloc (r_type)
&& h != NULL
&& h == tga)
|| (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))
{
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;
}
}
- if (htab->is_vxworks)
+ if (htab->elf.target_os == is_vxworks)
{
struct elf_dyn_relocs **pp;
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)
{
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. */
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;
}
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)
}
ifunc = NULL;
- if (!htab->is_vxworks)
+ if (htab->elf.target_os != is_vxworks)
{
struct plt_entry *ent;
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;
continue;
default:
- if (htab->is_vxworks
+ if (htab->elf.target_os == is_vxworks
&& elf_vxworks_finish_dynamic_entry (output_bfd, &dyn))
break;
continue;
}
/* 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)
#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)
{
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;
/* 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;
};
return NULL;
}
- ret->vxworks_p = vxworks_object_p (abfd);
ret->fdpic_p = fdpic_object_p (abfd);
return &ret->root.root;
}
}
- if (htab->vxworks_p)
+ if (htab->root.target_os == is_vxworks)
{
if (!elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2))
return FALSE;
/* 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
}
}
- if (htab->vxworks_p)
+ if (htab->root.target_os == is_vxworks)
{
struct elf_dyn_relocs **pp;
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)
{
return FALSE;
}
}
- if (htab->vxworks_p
+ if (htab->root.target_os == is_vxworks
&& !elf_vxworks_add_dynamic_entries (output_bfd, info))
return FALSE;
}
/* 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"));
(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;
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. */
_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;
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;
(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;
#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 */
#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. */
#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
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)
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;
/* 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);
#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. */
|| 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 */
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
#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"
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;
}
/* 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;
/* 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. */
/* 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. */
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;
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
{
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;
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));
{
/* 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)))
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;
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);
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;
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
(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;
/* 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)
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;
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 */
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)
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;
}
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
/* 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
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;
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;
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;
/* 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)
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)
{
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
}
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);
/* 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;
}
}
- 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. */
/* 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;
== 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. */
/* 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;
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);
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")
&& !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)
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. */
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;
}
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
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;
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;
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;
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
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
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);
htab = (struct mips_elf_link_hash_table *) ret;
htab->use_plts_and_copy_relocs = TRUE;
- htab->is_vxworks = TRUE;
}
return ret;
}
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))
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
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;
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;
}
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;
}
}
- if (htab->is_vxworks)
+ if (htab->elf.target_os == is_vxworks)
{
struct elf_dyn_relocs **pp;
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)
{
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. */
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"));
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)
".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;
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. */
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)
/* 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);
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);
}
#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
{
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 */
}
}
- 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,
}
}
- 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; )
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,
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)
{
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. */
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;
}
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;
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
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)
{
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))
{
#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
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;
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. */