edir = (struct elf_nds32_link_hash_entry *) dir;
eind = (struct elf_nds32_link_hash_entry *) ind;
- if (ind->dyn_relocs != NULL)
- {
- if (dir->dyn_relocs != NULL)
- {
- struct elf_dyn_relocs **pp;
- struct elf_dyn_relocs *p;
-
- if (ind->root.type == bfd_link_hash_indirect)
- abort ();
-
- /* Add reloc counts against the weak sym to the strong sym
- list. Merge any entries against the same section. */
- for (pp = &ind->dyn_relocs; (p = *pp) != NULL;)
- {
- struct elf_dyn_relocs *q;
-
- for (q = dir->dyn_relocs; q != NULL; q = q->next)
- if (q->sec == p->sec)
- {
- q->pc_count += p->pc_count;
- q->count += p->count;
- *pp = p->next;
- break;
- }
- if (q == NULL)
- pp = &p->next;
- }
- *pp = dir->dyn_relocs;
- }
-
- dir->dyn_relocs = ind->dyn_relocs;
- ind->dyn_relocs = NULL;
- }
-
if (ind->root.type == bfd_link_hash_indirect)
{
if (dir->got.refcount <= 0)
_bfd_elf_link_hash_copy_indirect (info, dir, ind);
}
\f
-
-/* Find dynamic relocs for H that apply to read-only sections. */
-
-static asection *
-readonly_dynrelocs (struct elf_link_hash_entry *h)
-{
- struct elf_dyn_relocs *p;
-
- for (p = h->dyn_relocs; p != NULL; p = p->next)
- {
- asection *s = p->sec->output_section;
-
- if (s != NULL && (s->flags & SEC_READONLY) != 0)
- return p->sec;
- }
- return NULL;
-}
-
/* Adjust a symbol defined by a dynamic object and referenced by a
regular object. The current definition is in some section of the
dynamic object, but we're not including those sections. We have to
/* If we don't find any dynamic relocs in read-only sections, then
we'll be keeping the dynamic relocs and avoiding the copy reloc. */
- if (!readonly_dynrelocs (h))
+ if (!_bfd_elf_readonly_dynrelocs (h))
{
h->non_got_ref = 0;
return TRUE;
bfd_elf32_swap_reloca_out (output_bfd, rel, loc);
}
-/* Set DF_TEXTREL if we find any dynamic relocs that apply to
- read-only sections. */
-
-static bfd_boolean
-maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p)
-{
- asection *sec;
-
- if (h->root.type == bfd_link_hash_indirect)
- return TRUE;
-
- sec = readonly_dynrelocs (h);
- if (sec != NULL)
- {
- struct bfd_link_info *info = (struct bfd_link_info *) info_p;
-
- info->flags |= DF_TEXTREL;
- info->callbacks->minfo
- (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"),
- sec->owner, h->root.root.string, sec);
-
- /* Not an error, just cut short the traversal. */
- return FALSE;
- }
- return TRUE;
-}
-
/* Set the sizes of the dynamic sections. */
static bfd_boolean
/* If we're not using lazy TLS relocations, don't generate the
PLT and GOT entries they require. */
- if (!(info->flags & DF_BIND_NOW))
+ if ((info->flags & DF_BIND_NOW))
+ htab->root.tlsdesc_plt = 0;
+ else
{
- htab->dt_tlsdesc_got = htab->root.sgot->size;
+ htab->root.tlsdesc_got = htab->root.sgot->size;
htab->root.sgot->size += 4;
- htab->dt_tlsdesc_plt = htab->root.splt->size;
+ htab->root.tlsdesc_plt = htab->root.splt->size;
htab->root.splt->size += 4 * ARRAY_SIZE (dl_tlsdesc_lazy_trampoline);
}
}
if (htab->tls_desc_trampoline && plt)
{
- if (htab->dt_tlsdesc_plt
+ if (htab->root.tlsdesc_plt
&& (!add_dynamic_entry (DT_TLSDESC_PLT, 0)
|| !add_dynamic_entry (DT_TLSDESC_GOT, 0)))
return FALSE;
/* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0)
- elf_link_hash_traverse (&htab->root, maybe_set_textrel,
+ elf_link_hash_traverse (&htab->root,
+ _bfd_elf_maybe_set_textrel,
(void *) info);
if ((info->flags & DF_TEXTREL) != 0)
case DT_TLSDESC_PLT:
s = htab->root.splt;
dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset
- + htab->dt_tlsdesc_plt);
+ + htab->root.tlsdesc_plt);
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_TLSDESC_GOT:
s = htab->root.sgot;
dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset
- + htab->dt_tlsdesc_got);
+ + htab->root.tlsdesc_got);
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
}
PLT_ENTRY_SIZE;
}
- if (htab->dt_tlsdesc_plt)
+ if (htab->root.tlsdesc_plt)
{
/* Calculate addresses. */
asection *sgot = sgot = ehtab->sgot;
bfd_vma pltgot = sgotplt->output_section->vma
+ sgotplt->output_offset;
bfd_vma tlsdesc_got = sgot->output_section->vma + sgot->output_offset
- + htab->dt_tlsdesc_got;
+ + htab->root.tlsdesc_got;
/* Get GP offset. */
pltgot -= elf_gp (output_bfd) - 4; /* PLTGOT[1] */
dl_tlsdesc_lazy_trampoline[5] += 0xfff & pltgot;
/* Insert .plt. */
- nds32_put_trampoline (splt->contents + htab->dt_tlsdesc_plt,
+ nds32_put_trampoline (splt->contents + htab->root.tlsdesc_plt,
dl_tlsdesc_lazy_trampoline,
ARRAY_SIZE (dl_tlsdesc_lazy_trampoline));
}
return TRUE;
}
- /* Don't do anything special with non-loaded, non-alloced sections.
- In particular, any relocs in such sections should not affect GOT
- and PLT reference counting (ie. we don't allow them to create GOT
- or PLT entries), there's no possibility or desire to optimize TLS
- relocs, and there's not much point in propagating relocs to shared
- libs that the dynamic linker won't relocate. */
- if ((sec->flags & SEC_ALLOC) == 0)
- return TRUE;
-
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (abfd);
sym_hashes_end =