Add plt0_pad_byte and target_os fields to elf_x86_link_hash_table.
Replace elf_i386_backend_data and elf_x86_64_backend_data with
elf_x86_backend_data.
* elf32-i386.c (elf_i386_backend_data): Removed.
(get_elf_i386_backend_data): Likewise.
(elf_i386_arch_bed): Replace elf_i386_backend_data with
elf_x86_backend_data.
(elf_i386_get_synthetic_symtab): Likewise.
(elf_i386_nacl_arch_bed): Likewise.
(elf_i386_vxworks_arch_bed): Likewise.
(elf_i386_relocate_section): Check target_os instead of
is_vxworks.
(elf_i386_finish_dynamic_symbol): Likewise.
(elf_i386_finish_dynamic_sections): Use htab->plt0_pad_byte.
Check target_os instead of is_vxworks.
(elf_i386_link_setup_gnu_properties): Remove normal_target and
is_vxworks. Initialize plt0_pad_byte.
* elf64-x86-64.c (elf_x86_64_backend_data); Removed.
(get_elf_x86_64_arch_data): Likewise.
(get_elf_x86_64_backend_data): Likewise.
(elf_x86_64_arch_bed): Replace elf_x86_64_backend_data with
elf_x86_backend_data.
(elf_x86_64_get_synthetic_symtab): Likewise.
(elf_x86_64_nacl_arch_bed): Likewise.
(elf_x86_64_link_setup_gnu_properties): Remove is_vxworks and
normal_target. Initialize plt0_pad_byte.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Check target_os
instead of is_vxworks.
(_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_hash_table_create): Initialize target_os.
(_bfd_x86_elf_link_setup_gnu_properties): Remove is_vxworks.
Update normal_target. Set up plt0_pad_byte. Check target_os
instead of is_vxworks.
* elfxx-x86.h (elf_x86_target_os): New.
(elf_x86_backend_data): Likewise.
(get_elf_x86_backend_data): Likewise.
(elf_x86_link_hash_table): Remove is_vxworks. Add plt0_pad_byte
and target_os.
(elf_x86_init_table): Remove normal_target and is_vxworks. Add
plt0_pad_byte.
+2017-10-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf32-i386.c (elf_i386_backend_data): Removed.
+ (get_elf_i386_backend_data): Likewise.
+ (elf_i386_arch_bed): Replace elf_i386_backend_data with
+ elf_x86_backend_data.
+ (elf_i386_get_synthetic_symtab): Likewise.
+ (elf_i386_nacl_arch_bed): Likewise.
+ (elf_i386_vxworks_arch_bed): Likewise.
+ (elf_i386_relocate_section): Check target_os instead of
+ is_vxworks.
+ (elf_i386_finish_dynamic_symbol): Likewise.
+ (elf_i386_finish_dynamic_sections): Use htab->plt0_pad_byte.
+ Check target_os instead of is_vxworks.
+ (elf_i386_link_setup_gnu_properties): Remove normal_target and
+ is_vxworks. Initialize plt0_pad_byte.
+ * elf64-x86-64.c (elf_x86_64_backend_data); Removed.
+ (get_elf_x86_64_arch_data): Likewise.
+ (get_elf_x86_64_backend_data): Likewise.
+ (elf_x86_64_arch_bed): Replace elf_x86_64_backend_data with
+ elf_x86_backend_data.
+ (elf_x86_64_get_synthetic_symtab): Likewise.
+ (elf_x86_64_nacl_arch_bed): Likewise.
+ (elf_x86_64_link_setup_gnu_properties): Remove is_vxworks and
+ normal_target. Initialize plt0_pad_byte.
+ * elfxx-x86.c (elf_x86_allocate_dynrelocs): Check target_os
+ instead of is_vxworks.
+ (_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_hash_table_create): Initialize target_os.
+ (_bfd_x86_elf_link_setup_gnu_properties): Remove is_vxworks.
+ Update normal_target. Set up plt0_pad_byte. Check target_os
+ instead of is_vxworks.
+ * elfxx-x86.h (elf_x86_target_os): New.
+ (elf_x86_backend_data): Likewise.
+ (get_elf_x86_backend_data): Likewise.
+ (elf_x86_link_hash_table): Remove is_vxworks. Add plt0_pad_byte
+ and target_os.
+ (elf_x86_init_table): Remove normal_target and is_vxworks. Add
+ plt0_pad_byte.
+
2017-10-14 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_finish_dynamic_sections): Call
#define PLTRESOLVE_RELOCS 2
#define PLT_NON_JUMP_SLOT_RELOCS 2
-/* Architecture-specific backend data for i386. */
-
-struct elf_i386_backend_data
-{
- /* Value used to fill the unused bytes of the first PLT entry. */
- bfd_byte plt0_pad_byte;
-
- /* Target system. */
- enum
- {
- is_normal,
- is_vxworks,
- is_nacl
- } os;
-};
-
-#define get_elf_i386_backend_data(abfd) \
- ((const struct elf_i386_backend_data *) \
- get_elf_backend_data (abfd)->arch_data)
-
/* These are the standard parameters. */
-static const struct elf_i386_backend_data elf_i386_arch_bed =
+static const struct elf_x86_backend_data elf_i386_arch_bed =
{
- 0, /* plt0_pad_byte */
is_normal /* os */
};
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->is_vxworks
+ is_vxworks_tls = (htab->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->is_vxworks)
+ if (htab->target_os == is_vxworks)
{
int s, k, reloc_index;
{
/* Fill in the special first entry in the procedure linkage
table. */
- const struct elf_i386_backend_data *abed
- = get_elf_i386_backend_data (output_bfd);
-
memcpy (htab->elf.splt->contents, htab->plt.plt0_entry,
htab->lazy_plt->plt0_entry_size);
memset (htab->elf.splt->contents + htab->lazy_plt->plt0_entry_size,
- abed->plt0_pad_byte,
+ htab->plt0_pad_byte,
htab->plt.plt_entry_size - htab->lazy_plt->plt0_entry_size);
if (!bfd_link_pic (info))
{
htab->elf.splt->contents
+ htab->lazy_plt->plt0_got2_offset);
- if (htab->is_vxworks)
+ if (htab->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_i386_backend_data (abfd)->os)
+ switch (get_elf_x86_backend_data (abfd)->target_os)
{
case is_normal:
non_lazy_plt = &elf_i386_non_lazy_plt;
{
struct elf_x86_init_table init_table;
- init_table.normal_target = FALSE;
- init_table.is_vxworks = FALSE;
- switch (get_elf_i386_backend_data (info->output_bfd)->os)
+ switch (get_elf_x86_backend_data (info->output_bfd)->target_os)
{
case is_normal:
+ init_table.plt0_pad_byte = 0x0;
init_table.lazy_plt = &elf_i386_lazy_plt;
init_table.non_lazy_plt = &elf_i386_non_lazy_plt;
init_table.lazy_ibt_plt = &elf_i386_lazy_ibt_plt;
init_table.non_lazy_ibt_plt = &elf_i386_non_lazy_ibt_plt;
- init_table.normal_target = TRUE;
break;
case is_vxworks:
+ init_table.plt0_pad_byte = 0x90;
init_table.lazy_plt = &elf_i386_lazy_plt;
init_table.non_lazy_plt = NULL;
init_table.lazy_ibt_plt = NULL;
init_table.non_lazy_ibt_plt = NULL;
- init_table.is_vxworks = TRUE;
break;
case is_nacl:
+ init_table.plt0_pad_byte = 0x90;
init_table.lazy_plt = &elf_i386_nacl_plt;
init_table.non_lazy_plt = NULL;
init_table.lazy_ibt_plt = NULL;
|| 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_i386_backend_data parameters for eh_frame_plt offsets!"
+# error "Need elf_x86_backend_data 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_i386_backend_data elf_i386_nacl_arch_bed =
+static const struct elf_x86_backend_data elf_i386_nacl_arch_bed =
{
- 0x90, /* plt0_pad_byte: nop insn */
is_nacl /* os */
};
#undef elf_backend_plt_alignment
#define elf_backend_plt_alignment 4
-static const struct elf_i386_backend_data elf_i386_vxworks_arch_bed =
+static const struct elf_x86_backend_data elf_i386_vxworks_arch_bed =
{
- 0x90, /* plt0_pad_byte */
is_vxworks /* os */
};
DW_CFA_nop, DW_CFA_nop, DW_CFA_nop
};
-/* Architecture-specific backend data for x86-64. */
-
-struct elf_x86_64_backend_data
-{
- /* Target system. */
- enum
- {
- is_normal,
- is_nacl
- } os;
-};
-
-#define get_elf_x86_64_arch_data(bed) \
- ((const struct elf_x86_64_backend_data *) (bed)->arch_data)
-
-#define get_elf_x86_64_backend_data(abfd) \
- get_elf_x86_64_arch_data (get_elf_backend_data (abfd))
-
/* These are the standard parameters. */
static const struct elf_x86_lazy_plt_layout elf_x86_64_lazy_plt =
{
sizeof (elf_x86_64_eh_frame_non_lazy_plt) /* eh_frame_plt_size */
};
-static const struct elf_x86_64_backend_data elf_x86_64_arch_bed =
+static const struct elf_x86_backend_data elf_x86_64_arch_bed =
{
is_normal /* os */
};
if (relsize <= 0)
return -1;
- if (get_elf_x86_64_backend_data (abfd)->os == is_normal)
+ if (get_elf_x86_backend_data (abfd)->target_os == is_normal)
{
lazy_plt = &elf_x86_64_lazy_plt;
non_lazy_plt = &elf_x86_64_non_lazy_plt;
!= (int) R_X86_64_GNU_VTENTRY))
abort ();
- init_table.is_vxworks = FALSE;
- if (get_elf_x86_64_backend_data (info->output_bfd)->os == is_normal)
+ /* This is unused for x86-64. */
+ init_table.plt0_pad_byte = 0x90;
+
+ if (get_elf_x86_backend_data (info->output_bfd)->target_os
+ == is_normal)
{
if (info->bndplt)
{
init_table.lazy_ibt_plt = &elf_x32_lazy_ibt_plt;
init_table.non_lazy_ibt_plt = &elf_x32_non_lazy_ibt_plt;
}
- init_table.normal_target = TRUE;
}
else
{
init_table.non_lazy_plt = NULL;
init_table.lazy_ibt_plt = NULL;
init_table.non_lazy_ibt_plt = NULL;
- init_table.normal_target = FALSE;
}
if (ABI_64_P (info->output_bfd))
|| 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_64_backend_data parameters for eh_frame_plt offsets!"
+# error "Need elf_x86_backend_data 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_64_backend_data elf_x86_64_nacl_arch_bed =
+static const struct elf_x86_backend_data elf_x86_64_nacl_arch_bed =
{
is_nacl /* os */
};
}
}
- if (htab->is_vxworks && !bfd_link_pic (info))
+ if (htab->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->is_vxworks)
+ if (htab->target_os == is_vxworks)
{
struct elf_dyn_relocs **pp;
for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
}
}
ret->target_id = bed->target_id;
+ 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->is_vxworks
+ else if (htab->target_os == is_vxworks
&& strcmp (p->sec->output_section->name,
".tls_vars") == 0)
{
return FALSE;
}
}
- if (htab->is_vxworks
+ if (htab->target_os == is_vxworks
&& !elf_vxworks_add_dynamic_entries (output_bfd, info))
return FALSE;
}
switch (dyn.d_tag)
{
default:
- if (htab->is_vxworks
+ if (htab->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->is_vxworks)))
+ && htab->target_os != is_vxworks)))
{
for (p = eh->dyn_relocs; p != NULL; p = p->next)
{
if (htab == NULL)
return pbfd;
- htab->is_vxworks = init_table->is_vxworks;
htab->r_info = init_table->r_info;
htab->r_sym = init_table->r_sym;
if (bfd_link_relocatable (info))
return pbfd;
+ htab->plt0_pad_byte = init_table->plt0_pad_byte;
+
use_ibt_plt = info->ibtplt || info->ibt;
if (!use_ibt_plt && pbfd != NULL)
{
}
}
+ /* Return if there are no normal input files. */
+ if (dynobj == NULL)
+ return pbfd;
+
/* Even when lazy binding is disabled by "-z now", the PLT0 entry may
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 = init_table->normal_target;
+ normal_target = htab->target_os == is_normal;
if (normal_target)
{
htab->plt.eh_frame_plt = htab->lazy_plt->eh_frame_plt;
}
- /* Return if there are no normal input files. */
- if (dynobj == NULL)
- return pbfd;
-
- if (htab->is_vxworks
+ if (htab->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_vxworks,
+ is_nacl
+};
+
/* x86 ELF linker hash table. */
struct elf_x86_link_hash_table
to read-only sections. */
bfd_boolean readonly_dynrelocs_against_ifunc;
- /* TRUE if this is a VxWorks x86 target. This is only used for
- i386. */
- bfd_boolean is_vxworks;
-
/* The (unloaded but important) .rel.plt.unloaded section on VxWorks.
This is used for i386 only. */
asection *srelplt2;
yet. This is only used for x86-64. */
bfd_vma tlsdesc_plt;
+ /* Value used to fill the unused bytes of the first PLT entry. This
+ is only used for i386. */
+ bfd_byte plt0_pad_byte;
+
bfd_vma (*r_info) (bfd_vma, bfd_vma);
bfd_vma (*r_sym) (bfd_vma);
bfd_boolean (*is_reloc_section) (const char *);
enum elf_target_id target_id;
+ enum elf_x86_target_os target_os;
unsigned int sizeof_reloc;
unsigned int dt_reloc;
unsigned int dt_reloc_sz;
const char *tls_get_addr;
};
+/* 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. */
/* The non-lazy PLT layout for IBT. */
const struct elf_x86_non_lazy_plt_layout *non_lazy_ibt_plt;
- /* TRUE if this is a normal x86 target. */
- bfd_boolean normal_target;
-
- /* TRUE if this is a VxWorks x86 target. */
- bfd_boolean is_vxworks;
+ bfd_byte plt0_pad_byte;
bfd_vma (*r_info) (bfd_vma, bfd_vma);
bfd_vma (*r_sym) (bfd_vma);