return TRUE;
}
+static bfd_boolean
+is_ppc64_target (const struct bfd_target *targ)
+{
+ extern const bfd_target bfd_elf64_powerpc_vec;
+ extern const bfd_target bfd_elf64_powerpcle_vec;
+
+ return targ == &bfd_elf64_powerpc_vec || targ == &bfd_elf64_powerpcle_vec;
+}
+
/* Fix bad default arch selected for a 64 bit input bfd when the
default is 32 bit. */
entry syms. */
static long
-ppc64_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms,
- long dynsymcount, asymbol **dynsyms,
+ppc64_elf_get_synthetic_symtab (bfd *abfd,
+ long static_count, asymbol **static_syms,
+ long dyn_count, asymbol **dyn_syms,
asymbol **ret)
{
asymbol *s;
long i;
long count;
char *names;
- long codesecsym, codesecsymend, secsymend, opdsymend;
+ long symcount, codesecsym, codesecsymend, secsymend, opdsymend;
asection *opd;
bfd_boolean relocatable = (abfd->flags & (EXEC_P | DYNAMIC)) == 0;
- asymbol **sy = NULL;
+ asymbol **syms;
*ret = NULL;
if (opd == NULL)
return 0;
+ symcount = static_count;
if (!relocatable)
- {
- if (symcount != 0 && dynsymcount != 0)
- {
- /* Use both symbol tables. */
- sy = bfd_malloc ((symcount + dynsymcount + 1) * sizeof (*syms));
- if (sy == NULL)
- return 0;
- memcpy (sy, syms, symcount * sizeof (*syms));
- memcpy (sy + symcount, dynsyms, (dynsymcount + 1) * sizeof (*syms));
- syms = sy;
- symcount = symcount + dynsymcount;
- }
- else if (symcount == 0)
- {
- syms = dynsyms;
- symcount = dynsymcount;
- }
- }
-
+ symcount += dyn_count;
if (symcount == 0)
return 0;
+ syms = bfd_malloc ((symcount + 1) * sizeof (*syms));
+ if (syms == NULL)
+ return 0;
+
+ if (!relocatable && static_count != 0 && dyn_count != 0)
+ {
+ /* Use both symbol tables. */
+ memcpy (syms, static_syms, static_count * sizeof (*syms));
+ memcpy (syms + static_count, dyn_syms, (dyn_count + 1) * sizeof (*syms));
+ }
+ else if (!relocatable && static_count == 0)
+ memcpy (syms, dyn_syms, (symcount + 1) * sizeof (*syms));
+ else
+ memcpy (syms, static_syms, (symcount + 1) * sizeof (*syms));
+
synthetic_opd = opd;
synthetic_relocatable = relocatable;
- qsort (syms, symcount, sizeof (asymbol *), compare_symbols);
+ qsort (syms, symcount, sizeof (*syms), compare_symbols);
if (!relocatable && symcount > 1)
{
arelent *r;
size_t size;
long relcount;
- asection *relopd;
slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
- relopd = opd;
relcount = (opd->flags & SEC_RELOC) ? opd->reloc_count : 0;
if (! relcount
- || ! (*slurp_relocs) (abfd, relopd, syms, FALSE))
+ || ! (*slurp_relocs) (abfd, opd, static_syms, FALSE))
goto done;
size = 0;
- for (i = secsymend, r = relopd->relocation; i < opdsymend; ++i)
+ for (i = secsymend, r = opd->relocation; i < opdsymend; ++i)
{
asymbol *sym;
- while (r < relopd->relocation + relcount
+ while (r < opd->relocation + relcount
&& r->address < syms[i]->value + opd->vma)
++r;
- if (r == relopd->relocation + relcount)
+ if (r == opd->relocation + relcount)
break;
if (r->address != syms[i]->value + opd->vma)
names = (char *) (s + count);
- for (i = secsymend, r = relopd->relocation; i < opdsymend; ++i)
+ for (i = secsymend, r = opd->relocation; i < opdsymend; ++i)
{
asymbol *sym;
- while (r < relopd->relocation + relcount
+ while (r < opd->relocation + relcount
&& r->address < syms[i]->value + opd->vma)
++r;
- if (r == relopd->relocation + relcount)
+ if (r == opd->relocation + relcount)
break;
if (r->address != syms[i]->value + opd->vma)
}
done:
- if (sy != NULL)
- free (sy);
+ free (syms);
return count;
}
\f
struct bfd_link_info *info)
{
struct ppc_link_hash_table *htab;
- extern const bfd_target bfd_elf64_powerpc_vec;
- extern const bfd_target bfd_elf64_powerpcle_vec;
htab = ppc_hash_table (info);
- if (htab->elf.root.creator != &bfd_elf64_powerpc_vec
- && htab->elf.root.creator != &bfd_elf64_powerpcle_vec)
+ if (!is_ppc64_target (htab->elf.root.creator))
return TRUE;
elf_link_hash_traverse (&htab->elf, add_symbol_adjust, info);
Elf_Internal_Shdr *symtab_hdr;
asection *srel;
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+ if (!is_ppc64_target (ibfd->xvec))
continue;
if (ppc64_tlsld_got (ibfd)->refcount > 0)
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
{
+ if (!is_ppc64_target (ibfd->xvec))
+ continue;
+
s = ppc64_elf_tdata (ibfd)->got;
if (s != NULL && s != htab->got)
{
}
/* We need to handle writing out multiple GOT sections ourselves,
- since we didn't add them to DYNOBJ. */
+ since we didn't add them to DYNOBJ. We know dynobj is the first
+ bfd. */
while ((dynobj = dynobj->link_next) != NULL)
{
asection *s;
+
+ if (!is_ppc64_target (dynobj->xvec))
+ continue;
+
s = ppc64_elf_tdata (dynobj)->got;
if (s != NULL
&& s->size != 0