plt_entry_size = htab->plt.plt_entry_size;
- resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
- bed->target_id,
- eh->has_got_reloc,
- eh);
+ resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
/* Clear the reference count of function pointer relocations if
symbol isn't a normal function. */
return CONST_STRNEQ (secname, ".rel");
}
-#ifdef BFD64
static bfd_boolean
elf_x86_64_is_reloc_section (const char *secname)
{
return CONST_STRNEQ (secname, ".rela");
}
-#endif
/* Create an x86 ELF linker hash table. */
return NULL;
}
-#ifdef BFD64
- /* NB: If BFD64 isn't defined, only i386 will be supported. */
if (bed->target_id == X86_64_ELF_DATA)
{
ret->is_reloc_section = elf_x86_64_is_reloc_section;
}
if (ABI_64_P (abfd))
{
- ret->r_info = elf64_r_info;
- ret->r_sym = elf64_r_sym;
ret->sizeof_reloc = sizeof (Elf64_External_Rela);
ret->pointer_r_type = R_X86_64_64;
ret->dynamic_interpreter = ELF64_DYNAMIC_INTERPRETER;
ret->dynamic_interpreter_size = sizeof ELF64_DYNAMIC_INTERPRETER;
}
else
-#endif
{
- ret->r_info = elf32_r_info;
- ret->r_sym = elf32_r_sym;
if (bed->target_id == X86_64_ELF_DATA)
{
ret->sizeof_reloc = sizeof (Elf32_External_Rela);
htab = elf_x86_hash_table (info, bed->target_id);
if (htab)
{
- struct elf_link_hash_entry *h
- = elf_link_hash_lookup (elf_hash_table (info),
+ struct elf_link_hash_entry *h;
+
+ h = elf_link_hash_lookup (elf_hash_table (info),
htab->tls_get_addr,
FALSE, FALSE, FALSE);
if (h != NULL)
- ((struct elf_x86_link_hash_entry *) h)->tls_get_addr = 1;
+ elf_x86_hash_entry (h)->tls_get_addr = 1;
+
+ /* "__ehdr_start" will be defined by linker as a hidden symbol
+ later if it is referenced and not defined. */
+ h = elf_link_hash_lookup (elf_hash_table (info),
+ "__ehdr_start",
+ FALSE, FALSE, FALSE);
+ if (h != NULL
+ && (h->root.type == bfd_link_hash_new
+ || h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak
+ || h->root.type == bfd_link_hash_common))
+ {
+ elf_x86_hash_entry (h)->local_ref = 2;
+ elf_x86_hash_entry (h)->linker_def = 1;
+ }
}
}
_bfd_x86_elf_fixup_symbol (struct bfd_link_info *info,
struct elf_link_hash_entry *h)
{
- if (h->dynindx != -1)
+ if (h->dynindx != -1
+ && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, elf_x86_hash_entry (h)))
{
- const struct elf_backend_data *bed
- = get_elf_backend_data (info->output_bfd);
- if (UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
- bed->target_id,
- elf_x86_hash_entry (h)->has_got_reloc,
- elf_x86_hash_entry (h)))
- {
- h->dynindx = -1;
- _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
- h->dynstr_index);
- }
+ h->dynindx = -1;
+ _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
+ h->dynstr_index);
}
return TRUE;
}
_bfd_x86_elf_link_symbol_references_local (struct bfd_link_info *info,
struct elf_link_hash_entry *h)
{
- struct elf_x86_link_hash_entry *eh
- = (struct elf_x86_link_hash_entry *) h;
+ struct elf_x86_link_hash_entry *eh = elf_x86_hash_entry (h);
+ struct elf_x86_link_hash_table *htab
+ = (struct elf_x86_link_hash_table *) info->hash;
if (eh->local_ref > 1)
return TRUE;
return FALSE;
/* Unversioned symbols defined in regular objects can be forced local
- by linker version script. A weak undefined symbol can fored local
- if it has non-default visibility or "-z nodynamic-undefined-weak"
- is used. */
+ by linker version script. A weak undefined symbol is forced local
+ if
+ 1. It has non-default visibility. Or
+ 2. When building executable, there is no dynamic linker. Or
+ 3. or "-z nodynamic-undefined-weak" is used.
+ */
if (SYMBOL_REFERENCES_LOCAL (info, h)
- || ((ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
- || info->dynamic_undefined_weak == 0)
- && h->root.type == bfd_link_hash_undefweak)
+ || (h->root.type == bfd_link_hash_undefweak
+ && (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+ || (bfd_link_executable (info)
+ && htab->interp == NULL)
+ || info->dynamic_undefined_weak == 0))
|| ((h->def_regular || ELF_COMMON_DEF_P (h))
&& h->versioned == unversioned
&& info->version_info != NULL
bfd *
_bfd_x86_elf_link_setup_gnu_properties
- (struct bfd_link_info *info,
- struct elf_x86_plt_layout_table *plt_layout)
+ (struct bfd_link_info *info, struct elf_x86_init_table *init_table)
{
bfd_boolean normal_target;
bfd_boolean lazy_plt;
pbfd = _bfd_elf_link_setup_gnu_properties (info);
- if (bfd_link_relocatable (info))
- return pbfd;
-
bed = get_elf_backend_data (info->output_bfd);
htab = elf_x86_hash_table (info, bed->target_id);
if (htab == NULL)
return pbfd;
- htab->is_vxworks = plt_layout->is_vxworks;
+ 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;
use_ibt_plt = info->ibtplt || info->ibt;
if (!use_ibt_plt && pbfd != NULL)
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 = plt_layout->normal_target;
+ normal_target = init_table->normal_target;
if (normal_target)
{
if (use_ibt_plt)
{
- htab->lazy_plt = plt_layout->lazy_ibt_plt;
- htab->non_lazy_plt = plt_layout->non_lazy_ibt_plt;
+ htab->lazy_plt = init_table->lazy_ibt_plt;
+ htab->non_lazy_plt = init_table->non_lazy_ibt_plt;
}
else
{
- htab->lazy_plt = plt_layout->lazy_plt;
- htab->non_lazy_plt = plt_layout->non_lazy_plt;
+ htab->lazy_plt = init_table->lazy_plt;
+ htab->non_lazy_plt = init_table->non_lazy_plt;
}
}
else
{
- htab->lazy_plt = plt_layout->lazy_plt;
+ htab->lazy_plt = init_table->lazy_plt;
htab->non_lazy_plt = NULL;
}