if (! _bfd_elf_create_got_section (htab->elf.dynobj, info))
return FALSE;
- htab->got = bfd_get_section_by_name (htab->elf.dynobj, ".got");
+ htab->got = bfd_get_linker_section (htab->elf.dynobj, ".got");
if (!htab->got)
abort ();
}
return FALSE;
if (!htab->got)
- htab->got = bfd_get_section_by_name (dynobj, ".got");
- htab->plt = bfd_get_section_by_name (dynobj, ".plt");
- htab->relplt = bfd_get_section_by_name (dynobj, ".rela.plt");
- htab->dynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+ htab->got = bfd_get_linker_section (dynobj, ".got");
+ htab->plt = bfd_get_linker_section (dynobj, ".plt");
+ htab->relplt = bfd_get_linker_section (dynobj, ".rela.plt");
+ htab->dynbss = bfd_get_linker_section (dynobj, ".dynbss");
if (!info->shared)
- htab->relbss = bfd_get_section_by_name (dynobj, ".rela.bss");
+ htab->relbss = bfd_get_linker_section (dynobj, ".rela.bss");
if (!htab->got || !htab->plt || !htab->relplt || !htab->dynbss
|| (!info->shared && !htab->relbss))
/* Set the contents of the .interp section to the interpreter. */
if (info->executable)
{
- s = bfd_get_section_by_name (dynobj, ".interp");
+ s = bfd_get_linker_section (dynobj, ".interp");
if (s == NULL)
abort ();
s->size = sizeof ELF_DYNAMIC_INTERPRETER;
if (!htab->second_toc_pass)
{
/* Keep track of the first .toc or .got section for this input bfd. */
- if (htab->toc_bfd != isec->owner)
+ bfd_boolean new_bfd = htab->toc_bfd != isec->owner;
+
+ if (new_bfd)
{
htab->toc_bfd = isec->owner;
htab->toc_first_sec = isec;
/* Die if someone uses a linker script that doesn't keep input
file .toc and .got together. */
- if (elf_gp (isec->owner) != 0
+ if (new_bfd
+ && elf_gp (isec->owner) != 0
&& elf_gp (isec->owner) != off)
return FALSE;
for (; rel < relend; rel++)
{
enum elf_ppc64_reloc_type r_type;
- bfd_vma addend, orig_addend;
+ bfd_vma addend;
bfd_reloc_status_type r;
Elf_Internal_Sym *sym;
asection *sec;
struct ppc_stub_hash_entry *stub_entry;
bfd_vma max_br_offset;
bfd_vma from;
+ const Elf_Internal_Rela orig_rel = *rel;
r_type = ELF64_R_TYPE (rel->r_info);
r_symndx = ELF64_R_SYM (rel->r_info);
sym_name = NULL;
unresolved_reloc = FALSE;
warned = FALSE;
- orig_addend = rel->r_addend;
if (r_symndx < symtab_hdr->sh_info)
{
unresolved_reloc, warned);
sym_name = h_elf->root.root.string;
sym_type = h_elf->type;
+ if (sec != NULL
+ && sec->owner == output_bfd
+ && strcmp (sec->name, ".opd") == 0)
+ {
+ /* This is a symbol defined in a linker script. All
+ such are defined in output sections, even those
+ defined by simple assignment from a symbol defined in
+ an input section. Transfer the symbol to an
+ appropriate input .opd section, so that a branch to
+ this symbol will be mapped to the location specified
+ by the opd entry. */
+ struct bfd_link_order *lo;
+ for (lo = sec->map_head.link_order; lo != NULL; lo = lo->next)
+ if (lo->type == bfd_indirect_link_order)
+ {
+ asection *isec = lo->u.indirect.section;
+ if (h_elf->root.u.def.value >= isec->output_offset
+ && h_elf->root.u.def.value < (isec->output_offset
+ + isec->size))
+ {
+ h_elf->root.u.def.value -= isec->output_offset;
+ h_elf->root.u.def.section = isec;
+ sec = isec;
+ break;
+ }
+ }
+ }
}
h = (struct ppc_link_hash_entry *) h_elf;
&& h->oh != NULL
&& h->oh->is_func_descriptor)
fdh = ppc_follow_link (h->oh);
- stub_entry = ppc_get_stub_entry (input_section, sec, fdh, rel, htab);
+ stub_entry = ppc_get_stub_entry (input_section, sec, fdh, &orig_rel,
+ htab);
if (stub_entry != NULL
&& (stub_entry->stub_type == ppc_stub_plt_call
|| stub_entry->stub_type == ppc_stub_plt_call_r2save
;
else
{
+ BFD_ASSERT (h->elf.dynindx != -1);
indx = h->elf.dynindx;
unresolved_reloc = FALSE;
}
}
for (; ent != NULL; ent = ent->next)
- if (ent->addend == orig_addend
+ if (ent->addend == orig_rel.r_addend
&& ent->owner == input_bfd
&& ent->tls_type == tls_type)
break;
{
struct plt_entry *ent;
for (ent = h->elf.plt.plist; ent != NULL; ent = ent->next)
- if (ent->addend == orig_addend
+ if (ent->addend == orig_rel.r_addend
&& ent->plt.offset != (bfd_vma) -1)
{
relocation = (htab->plt->output_section->vma
else if (!SYMBOL_CALLS_LOCAL (info, &h->elf)
&& !is_opd
&& r_type != R_PPC64_TOC)
- outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type);
+ {
+ BFD_ASSERT (h->elf.dynindx != -1);
+ outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type);
+ }
else
{
/* This symbol is local, or marked to become local,
if (!((*info->callbacks->reloc_overflow)
(info, (h ? &h->elf.root : NULL), sym_name,
ppc64_elf_howto_table[r_type]->name,
- orig_addend, input_bfd, input_section, rel->r_offset)))
+ orig_rel.r_addend, input_bfd, input_section,
+ rel->r_offset)))
return FALSE;
}
else
return FALSE;
dynobj = htab->elf.dynobj;
- sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+ sdyn = bfd_get_linker_section (dynobj, ".dynamic");
if (htab->elf.dynamic_sections_created)
{