return TRUE;
}
+/* Choose whether to use htab->iplt or htab->pltlocal rather than the
+ usual htab->elf.splt section for a PLT entry. */
+
+static inline
+bfd_boolean use_local_plt (struct bfd_link_info *info,
+ struct elf_link_hash_entry *h)
+{
+ return (h == NULL
+ || h->dynindx == -1
+ || !elf_hash_table (info)->dynamic_sections_created);
+}
+
/* Allocate space in associated reloc sections for dynamic relocs. */
static bfd_boolean
struct ppc_elf_link_hash_entry *eh;
struct ppc_elf_link_hash_table *htab;
struct elf_dyn_relocs *p;
- bfd_boolean dyn;
if (h->root.type == bfd_link_hash_indirect)
return TRUE;
b) is an ifunc, or
c) has plt16 relocs and has been processed by adjust_dynamic_symbol, or
d) has plt16 relocs and we are linking statically. */
- dyn = htab->elf.dynamic_sections_created && h->dynindx != -1;
- if (dyn
+ if ((htab->elf.dynamic_sections_created && h->dynindx != -1)
|| h->type == STT_GNU_IFUNC
|| (h->needs_plt && h->dynamic_adjusted)
|| (h->needs_plt
if (ent->plt.refcount > 0)
{
asection *s = htab->elf.splt;
+ bfd_boolean dyn = !use_local_plt (info, h);
if (!dyn)
{
unresolved_reloc = FALSE;
plt = htab->elf.splt;
- if (!htab->elf.dynamic_sections_created
- || h == NULL
- || h->dynindx == -1)
+ if (use_local_plt (info, h))
{
if (ifunc != NULL)
plt = htab->elf.iplt;
for (ent = h->plt.plist; ent != NULL; ent = ent->next)
if (ent->plt.offset != (bfd_vma) -1)
{
+ bfd_boolean dyn = !use_local_plt (info, h);
+
if (!doneone)
{
Elf_Internal_Rela rela;
asection *plt = htab->elf.splt;
asection *relplt = htab->elf.srelplt;
- if (htab->plt_type == PLT_NEW
- || !htab->elf.dynamic_sections_created
- || h->dynindx == -1)
+ if (htab->plt_type == PLT_NEW || !dyn)
reloc_index = ent->plt.offset / 4;
else
{
/* This symbol has an entry in the procedure linkage table.
Set it up. */
- if (htab->plt_type == PLT_VXWORKS
- && htab->elf.dynamic_sections_created
- && h->dynindx != -1)
+ if (htab->plt_type == PLT_VXWORKS && dyn)
{
bfd_vma got_offset;
const bfd_vma *plt_entry;
else
{
rela.r_addend = 0;
- if (!htab->elf.dynamic_sections_created
- || h->dynindx == -1)
+ if (!dyn)
{
if (h->type == STT_GNU_IFUNC)
{
+ plt->output_offset
+ ent->plt.offset);
- if (htab->plt_type == PLT_OLD
- || !htab->elf.dynamic_sections_created
- || h->dynindx == -1)
+ if (htab->plt_type == PLT_OLD || !dyn)
{
/* We don't need to fill in the .plt. The ppc dynamic
linker will fill it in. */
if (relplt != NULL)
{
/* Fill in the entry in the .rela.plt section. */
- if (!htab->elf.dynamic_sections_created
- || h->dynindx == -1)
+ if (!dyn)
{
if (h->type == STT_GNU_IFUNC)
rela.r_info = ELF32_R_INFO (0, R_PPC_IRELATIVE);
doneone = TRUE;
}
- if (htab->plt_type == PLT_NEW
- || !htab->elf.dynamic_sections_created
- || h->dynindx == -1)
+ if (htab->plt_type == PLT_NEW || !dyn)
{
unsigned char *p;
asection *plt = htab->elf.splt;
- if (!htab->elf.dynamic_sections_created
- || h->dynindx == -1)
+ if (!dyn)
{
if (h->type == STT_GNU_IFUNC)
plt = htab->elf.iplt;
return (struct ppc_link_hash_entry *) ent;
}
+static inline struct elf_link_hash_entry *
+elf_hash_entry (struct ppc_link_hash_entry *ent)
+{
+ return (struct elf_link_hash_entry *) ent;
+}
+
/* ppc64 ELF linker hash table. */
struct ppc_link_hash_table
is_tls_get_addr (struct elf_link_hash_entry *h,
struct ppc_link_hash_table *htab)
{
- return (h == (struct elf_link_hash_entry *) htab->tls_get_addr_fd
- || h == (struct elf_link_hash_entry *) htab->tga_desc_fd
- || h == (struct elf_link_hash_entry *) htab->tls_get_addr
- || h == (struct elf_link_hash_entry *) htab->tga_desc);
+ return (h == elf_hash_entry (htab->tls_get_addr_fd)
+ || h == elf_hash_entry (htab->tga_desc_fd)
+ || h == elf_hash_entry (htab->tls_get_addr)
+ || h == elf_hash_entry (htab->tga_desc));
}
static bfd_boolean func_desc_adjust (struct elf_link_hash_entry *, void *);
if (tga_fd != NULL)
{
htab->tls_get_addr_fd = ppc_elf_hash_entry (opt_fd);
- tga = (struct elf_link_hash_entry *) htab->tls_get_addr;
+ tga = elf_hash_entry (htab->tls_get_addr);
if (opt != NULL && tga != NULL)
{
tga->root.type = bfd_link_hash_indirect;
any of HASH1, HASH2, HASH3, or HASH4. */
static bfd_boolean
-branch_reloc_hash_match (const bfd *ibfd,
- const Elf_Internal_Rela *rel,
- const struct ppc_link_hash_entry *hash1,
- const struct ppc_link_hash_entry *hash2,
- const struct ppc_link_hash_entry *hash3,
- const struct ppc_link_hash_entry *hash4)
+branch_reloc_hash_match (bfd *ibfd,
+ Elf_Internal_Rela *rel,
+ struct ppc_link_hash_entry *hash1,
+ struct ppc_link_hash_entry *hash2,
+ struct ppc_link_hash_entry *hash3,
+ struct ppc_link_hash_entry *hash4)
{
Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (ibfd);
enum elf_ppc64_reloc_type r_type = ELF64_R_TYPE (rel->r_info);
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
h = elf_follow_link (h);
- if (h == (struct elf_link_hash_entry *) hash1
- || h == (struct elf_link_hash_entry *) hash2
- || h == (struct elf_link_hash_entry *) hash3
- || h == (struct elf_link_hash_entry *) hash4)
+ if (h == elf_hash_entry (hash1)
+ || h == elf_hash_entry (hash2)
+ || h == elf_hash_entry (hash3)
+ || h == elf_hash_entry (hash4))
return TRUE;
}
return FALSE;
return TRUE;
}
+/* Choose whether to use htab->iplt or htab->pltlocal rather than the
+ usual htab->elf.splt section for a PLT entry. */
+
+static inline
+bfd_boolean use_local_plt (struct bfd_link_info *info,
+ struct elf_link_hash_entry *h)
+{
+ return (h == NULL
+ || h->dynindx == -1
+ || !elf_hash_table (info)->dynamic_sections_created);
+}
+
/* Allocate space in .plt, .got and associated reloc sections for
dynamic relocs. */
for (pent = h->plt.plist; pent != NULL; pent = pent->next)
if (pent->plt.refcount > 0)
{
- if (!htab->elf.dynamic_sections_created
- || h->dynindx == -1)
+ if (use_local_plt (info, h))
{
if (h->type == STT_GNU_IFUNC)
{
abort ();
plt = htab->elf.splt;
- if (!htab->elf.dynamic_sections_created
- || stub_entry->h == NULL
- || stub_entry->h->elf.dynindx == -1)
+ if (use_local_plt (info, elf_hash_entry (stub_entry->h)))
{
if (stub_entry->symtype == STT_GNU_IFUNC)
plt = htab->elf.iplt;
abort ();
plt = htab->elf.splt;
- if (!htab->elf.dynamic_sections_created
- || stub_entry->h == NULL
- || stub_entry->h->elf.dynindx == -1)
+ if (use_local_plt (info, elf_hash_entry (stub_entry->h)))
{
if (stub_entry->symtype == STT_GNU_IFUNC)
plt = htab->elf.iplt;
abort ();
plt = htab->elf.splt;
- if (!htab->elf.dynamic_sections_created
- || stub_entry->h == NULL
- || stub_entry->h->elf.dynindx == -1)
+ if (use_local_plt (info, elf_hash_entry (stub_entry->h)))
{
if (stub_entry->symtype == STT_GNU_IFUNC)
plt = htab->elf.iplt;
if (targ >= (bfd_vma) -2)
abort ();
plt = htab->elf.splt;
- if (!htab->elf.dynamic_sections_created
- || stub_entry->h == NULL
- || stub_entry->h->elf.dynindx == -1)
+ if (use_local_plt (info, elf_hash_entry (stub_entry->h)))
{
if (stub_entry->symtype == STT_GNU_IFUNC)
plt = htab->elf.iplt;
asection *plt, *relplt;
bfd_byte *loc;
- if (!htab->elf.dynamic_sections_created
- || h->dynindx == -1)
+ if (use_local_plt (info, h))
{
if (!(h->def_regular
&& (h->root.type == bfd_link_hash_defined
p = s->contents + h->root.u.def.value;
plt = htab->elf.splt;
- if (!htab->elf.dynamic_sections_created
- || h->dynindx == -1)
+ if (use_local_plt (info, h))
{
if (h->type == STT_GNU_IFUNC)
plt = htab->elf.iplt;
bfd_vma got;
plt = htab->elf.splt;
- if (!htab->elf.dynamic_sections_created
- || h == NULL
- || h->elf.dynindx == -1)
+ if (use_local_plt (info, elf_hash_entry (h)))
{
if (h != NULL
? h->elf.type == STT_GNU_IFUNC