/* PowerPC64-specific support for 64-bit ELF.
- Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
- Free Software Foundation, Inc.
+ Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+ 2009 Free Software Foundation, Inc.
Written by Linus Nordberg, Swox AB <info@swox.com>,
based on elf32-ppc.c by Ian Lance Taylor.
Largely rewritten by Alan Modra <amodra@bigpond.net.au>
#define elf_backend_create_dynamic_sections ppc64_elf_create_dynamic_sections
#define elf_backend_copy_indirect_symbol ppc64_elf_copy_indirect_symbol
#define elf_backend_add_symbol_hook ppc64_elf_add_symbol_hook
-#define elf_backend_check_directives ppc64_elf_check_directives
+#define elf_backend_check_directives ppc64_elf_process_dot_syms
#define elf_backend_as_needed_cleanup ppc64_elf_as_needed_cleanup
#define elf_backend_archive_symbol_lookup ppc64_elf_archive_symbol_lookup
#define elf_backend_check_relocs ppc64_elf_check_relocs
0xfffc, /* dst_mask */
FALSE), /* pcrel_offset */
- /* Marker reloc for TLS. */
+ /* Marker relocs for TLS. */
HOWTO (R_PPC64_TLS,
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
0, /* dst_mask */
FALSE), /* pcrel_offset */
+ HOWTO (R_PPC64_TLSGD,
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC64_TLSGD", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ HOWTO (R_PPC64_TLSLD,
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC64_TLSLD", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
/* Computes the load module index of the load module that contains the
definition of its TLS sym. */
HOWTO (R_PPC64_DTPMOD64,
break;
case BFD_RELOC_PPC_TLS: r = R_PPC64_TLS;
break;
+ case BFD_RELOC_PPC_TLSGD: r = R_PPC64_TLSGD;
+ break;
+ case BFD_RELOC_PPC_TLSLD: r = R_PPC64_TLSLD;
+ break;
case BFD_RELOC_PPC_DTPMOD: r = R_PPC64_DTPMOD64;
break;
case BFD_RELOC_PPC_TPREL16: r = R_PPC64_TPREL16;
#define ppc64_tlsld_got(bfd) \
(&ppc64_elf_tdata (bfd)->tlsld_got)
+#define is_ppc64_elf(bfd) \
+ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
+ && elf_object_id (bfd) == PPC64_ELF_TDATA)
+
/* Override the generic function because we store some extras. */
static bfd_boolean
ppc64_elf_mkobject (bfd *abfd)
{
- if (abfd->tdata.any == NULL)
- {
- bfd_size_type amt = sizeof (struct ppc64_elf_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
- if (abfd->tdata.any == NULL)
- return FALSE;
- }
- return bfd_elf_mkobject (abfd);
-}
-
-/* Return 1 if target is one of ours. */
-
-static bfd_boolean
-is_ppc64_elf_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;
+ return bfd_elf_allocate_object (abfd, sizeof (struct ppc64_elf_obj_tdata),
+ PPC64_ELF_TDATA);
}
/* Fix bad default arch selected for a 64 bit input bfd when the
long *adjust;
} opd;
- /* An array for toc sections, indexed by offset/8.
- Specifies the relocation symbol index used at a given toc offset. */
- unsigned *t_symndx;
+ /* An array for toc sections, indexed by offset/8. */
+ struct _toc_sec_data
+ {
+ /* Specifies the relocation symbol index used at a given toc offset. */
+ unsigned *symndx;
+
+ /* And the relocation addend. */
+ bfd_vma *add;
+ } toc;
} u;
enum _ppc64_sec_type sec_type:2;
}
\f
/* Parameters for the qsort hook. */
-static asection *synthetic_opd;
static bfd_boolean synthetic_relocatable;
/* qsort comparison function for ppc64_elf_get_synthetic_symtab. */
return 1;
/* then .opd symbols. */
- if (a->section == synthetic_opd && b->section != synthetic_opd)
+ if (strcmp (a->section->name, ".opd") == 0
+ && strcmp (b->section->name, ".opd") != 0)
return -1;
- if (a->section != synthetic_opd && b->section == synthetic_opd)
+ if (strcmp (a->section->name, ".opd") != 0
+ && strcmp (b->section->name, ".opd") == 0)
return 1;
/* then other code symbols. */
return NULL;
}
+static bfd_boolean
+section_covers_vma (bfd *abfd ATTRIBUTE_UNUSED, asection *section, void *ptr)
+{
+ bfd_vma vma = *(bfd_vma *) ptr;
+ return ((section->flags & SEC_ALLOC) != 0
+ && section->vma <= vma
+ && vma < section->vma + section->size);
+}
+
/* Create synthetic symbols, effectively restoring "dot-symbol" function
- entry syms. */
+ entry syms. Also generate @plt symbols for the glink branch table. */
static long
ppc64_elf_get_synthetic_symtab (bfd *abfd,
else
memcpy (syms, static_syms, (symcount + 1) * sizeof (*syms));
- synthetic_opd = opd;
synthetic_relocatable = relocatable;
qsort (syms, symcount, sizeof (*syms), compare_symbols);
}
i = 0;
- if (syms[i]->section == opd)
+ if (strcmp (syms[i]->section->name, ".opd") == 0)
++i;
codesecsym = i;
secsymend = i;
for (; i < symcount; ++i)
- if (syms[i]->section != opd)
+ if (strcmp (syms[i]->section->name, ".opd") != 0)
break;
opdsymend = i;
symcount = i;
count = 0;
- if (opdsymend == secsymend)
- goto done;
if (relocatable)
{
size_t size;
long relcount;
+ if (opdsymend == secsymend)
+ goto done;
+
slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
relcount = (opd->flags & SEC_RELOC) ? opd->reloc_count : 0;
if (relcount == 0)
size_t len;
*s = *syms[i];
+ s->flags |= BSF_SYNTHETIC;
s->section = sym->section;
s->value = sym->value + r->addend;
s->name = names;
}
else
{
+ bfd_boolean (*slurp_relocs) (bfd *, asection *, asymbol **, bfd_boolean);
bfd_byte *contents;
size_t size;
+ long plt_count = 0;
+ bfd_vma glink_vma = 0, resolv_vma = 0;
+ asection *dynamic, *glink = NULL, *relplt = NULL;
+ arelent *p;
if (!bfd_malloc_and_get_section (abfd, opd, &contents))
{
}
}
+ /* Get start of .glink stubs from DT_PPC64_GLINK. */
+ if (dyn_count != 0
+ && (dynamic = bfd_get_section_by_name (abfd, ".dynamic")) != NULL)
+ {
+ bfd_byte *dynbuf, *extdyn, *extdynend;
+ size_t extdynsize;
+ void (*swap_dyn_in) (bfd *, const void *, Elf_Internal_Dyn *);
+
+ if (!bfd_malloc_and_get_section (abfd, dynamic, &dynbuf))
+ goto free_contents_and_exit;
+
+ extdynsize = get_elf_backend_data (abfd)->s->sizeof_dyn;
+ swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in;
+
+ extdyn = dynbuf;
+ extdynend = extdyn + dynamic->size;
+ for (; extdyn < extdynend; extdyn += extdynsize)
+ {
+ Elf_Internal_Dyn dyn;
+ (*swap_dyn_in) (abfd, extdyn, &dyn);
+
+ if (dyn.d_tag == DT_NULL)
+ break;
+
+ if (dyn.d_tag == DT_PPC64_GLINK)
+ {
+ /* The first glink stub starts at offset 32; see comment in
+ ppc64_elf_finish_dynamic_sections. */
+ glink_vma = dyn.d_un.d_val + 32;
+ /* The .glink section usually does not survive the final
+ link; search for the section (usually .text) where the
+ glink stubs now reside. */
+ glink = bfd_sections_find_if (abfd, section_covers_vma,
+ &glink_vma);
+ break;
+ }
+ }
+
+ free (dynbuf);
+ }
+
+ if (glink != NULL)
+ {
+ /* Determine __glink trampoline by reading the relative branch
+ from the first glink stub. */
+ bfd_byte buf[4];
+ if (bfd_get_section_contents (abfd, glink, buf,
+ glink_vma + 4 - glink->vma, 4))
+ {
+ unsigned int insn = bfd_get_32 (abfd, buf);
+ insn ^= B_DOT;
+ if ((insn & ~0x3fffffc) == 0)
+ resolv_vma = glink_vma + 4 + (insn ^ 0x2000000) - 0x2000000;
+ }
+
+ if (resolv_vma)
+ size += sizeof (asymbol) + sizeof ("__glink_PLTresolve");
+
+ relplt = bfd_get_section_by_name (abfd, ".rela.plt");
+ if (relplt != NULL)
+ {
+ slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
+ if (! (*slurp_relocs) (abfd, relplt, dyn_syms, TRUE))
+ goto free_contents_and_exit;
+
+ plt_count = relplt->size / sizeof (Elf64_External_Rela);
+ size += plt_count * sizeof (asymbol);
+
+ p = relplt->relocation;
+ for (i = 0; i < plt_count; i++, p++)
+ size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
+ }
+ }
+
s = *ret = bfd_malloc (size);
if (s == NULL)
goto free_contents_and_exit;
- names = (char *) (s + count);
+ names = (char *) (s + count + plt_count + (resolv_vma != 0));
for (i = secsymend; i < opdsymend; ++i)
{
if ((sec->flags & SEC_CODE) != 0)
s->section = sec;
}
+ s->flags |= BSF_SYNTHETIC;
s->value = ent - s->section->vma;
s->name = names;
*names++ = '.';
}
}
free (contents);
+
+ if (glink != NULL && relplt != NULL)
+ {
+ if (resolv_vma)
+ {
+ /* Add a symbol for the main glink trampoline. */
+ memset (s, 0, sizeof *s);
+ s->the_bfd = abfd;
+ s->flags = BSF_GLOBAL | BSF_SYNTHETIC;
+ s->section = glink;
+ s->value = resolv_vma - glink->vma;
+ s->name = names;
+ memcpy (names, "__glink_PLTresolve", sizeof ("__glink_PLTresolve"));
+ names += sizeof ("__glink_PLTresolve");
+ s++;
+ count++;
+ }
+
+ /* FIXME: It would be very much nicer to put sym@plt on the
+ stub rather than on the glink branch table entry. The
+ objdump disassembler would then use a sensible symbol
+ name on plt calls. The difficulty in doing so is
+ a) finding the stubs, and,
+ b) matching stubs against plt entries, and,
+ c) there can be multiple stubs for a given plt entry.
+
+ Solving (a) could be done by code scanning, but older
+ ppc64 binaries used different stubs to current code.
+ (b) is the tricky one since you need to known the toc
+ pointer for at least one function that uses a pic stub to
+ be able to calculate the plt address referenced.
+ (c) means gdb would need to set multiple breakpoints (or
+ find the glink branch itself) when setting breakpoints
+ for pending shared library loads. */
+ p = relplt->relocation;
+ for (i = 0; i < plt_count; i++, p++)
+ {
+ size_t len;
+
+ *s = **p->sym_ptr_ptr;
+ /* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since
+ we are defining a symbol, ensure one of them is set. */
+ if ((s->flags & BSF_LOCAL) == 0)
+ s->flags |= BSF_GLOBAL;
+ s->flags |= BSF_SYNTHETIC;
+ s->section = glink;
+ s->value = glink_vma - glink->vma;
+ s->name = names;
+ s->udata.p = NULL;
+ len = strlen ((*p->sym_ptr_ptr)->name);
+ memcpy (names, (*p->sym_ptr_ptr)->name, len);
+ names += len;
+ memcpy (names, "@plt", sizeof ("@plt"));
+ names += sizeof ("@plt");
+ s++;
+ glink_vma += 8;
+ if (i >= 0x8000)
+ glink_vma += 4;
+ }
+ count += plt_count;
+ }
}
done:
} plt;
};
-/* Of those relocs that might be copied as dynamic relocs, this macro
+/* Of those relocs that might be copied as dynamic relocs, this function
selects those that must be copied when linking a shared library,
even when the symbol is local. */
-#define MUST_BE_DYN_RELOC(RTYPE) \
- ((RTYPE) != R_PPC64_REL32 \
- && (RTYPE) != R_PPC64_REL64 \
- && (RTYPE) != R_PPC64_REL30)
+static int
+must_be_dyn_reloc (struct bfd_link_info *info,
+ enum elf_ppc64_reloc_type r_type)
+{
+ switch (r_type)
+ {
+ default:
+ return 1;
+
+ case R_PPC64_REL32:
+ case R_PPC64_REL64:
+ case R_PPC64_REL30:
+ return 0;
+
+ case R_PPC64_TPREL16:
+ case R_PPC64_TPREL16_LO:
+ case R_PPC64_TPREL16_HI:
+ case R_PPC64_TPREL16_HA:
+ case R_PPC64_TPREL16_DS:
+ case R_PPC64_TPREL16_LO_DS:
+ case R_PPC64_TPREL16_HIGHER:
+ case R_PPC64_TPREL16_HIGHERA:
+ case R_PPC64_TPREL16_HIGHEST:
+ case R_PPC64_TPREL16_HIGHESTA:
+ case R_PPC64_TPREL64:
+ return !info->executable;
+ }
+}
/* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
copying dynamic variables from a shared lib into an app's dynbss
/* Set on error. */
unsigned int stub_error:1;
- /* Temp used by ppc64_elf_check_directives. */
+ /* Temp used by ppc64_elf_process_dot_syms. */
unsigned int twiddled_syms:1;
/* Incremented every time we size stubs. */
flagword flags;
struct ppc_link_hash_table *htab = ppc_hash_table (info);
+ if (!is_ppc64_elf (abfd))
+ return FALSE;
+
if (!htab->got)
{
if (! _bfd_elf_create_got_section (htab->elf.dynobj, info))
/* Process list of dot-symbols we made in link_hash_newfunc. */
static bfd_boolean
-ppc64_elf_check_directives (bfd *ibfd, struct bfd_link_info *info)
+ppc64_elf_process_dot_syms (bfd *ibfd, struct bfd_link_info *info)
{
struct ppc_link_hash_table *htab;
struct ppc_link_hash_entry **p, *eh;
htab = ppc_hash_table (info);
- if (!is_ppc64_elf_target (htab->elf.root.creator))
+ if (!is_ppc64_elf (info->output_bfd))
return TRUE;
- if (is_ppc64_elf_target (ibfd->xvec))
+ if (is_ppc64_elf (ibfd))
{
p = &htab->dot_syms;
while ((eh = *p) != NULL)
const Elf_Internal_Rela *rel_end;
asection *sreloc;
asection **opd_sym_map;
+ struct elf_link_hash_entry *tga, *dottga;
if (info->relocatable)
return TRUE;
if ((sec->flags & SEC_ALLOC) == 0)
return TRUE;
+ BFD_ASSERT (is_ppc64_elf (abfd));
+
htab = ppc_hash_table (info);
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ tga = elf_link_hash_lookup (&htab->elf, "__tls_get_addr",
+ FALSE, FALSE, TRUE);
+ dottga = elf_link_hash_lookup (&htab->elf, ".__tls_get_addr",
+ FALSE, FALSE, TRUE);
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
sym_hashes_end = (sym_hashes
unsigned long r_symndx;
struct elf_link_hash_entry *h;
enum elf_ppc64_reloc_type r_type;
- int tls_type = 0;
+ int tls_type;
struct _ppc64_elf_section_data *ppc64_sec;
r_symndx = ELF64_R_SYM (rel->r_info);
h = (struct elf_link_hash_entry *) h->root.u.i.link;
}
+ tls_type = 0;
r_type = ELF64_R_TYPE (rel->r_info);
+ if (h != NULL && (h == tga || h == dottga))
+ switch (r_type)
+ {
+ default:
+ break;
+
+ case R_PPC64_REL24:
+ case R_PPC64_REL14:
+ case R_PPC64_REL14_BRTAKEN:
+ case R_PPC64_REL14_BRNTAKEN:
+ case R_PPC64_ADDR24:
+ case R_PPC64_ADDR14:
+ case R_PPC64_ADDR14_BRTAKEN:
+ case R_PPC64_ADDR14_BRNTAKEN:
+ if (rel != relocs
+ && (ELF64_R_TYPE (rel[-1].r_info) == R_PPC64_TLSGD
+ || ELF64_R_TYPE (rel[-1].r_info) == R_PPC64_TLSLD))
+ /* We have a new-style __tls_get_addr call with a marker
+ reloc. */
+ ;
+ else
+ /* Mark this section as having an old-style call. */
+ sec->has_tls_get_addr_call = 1;
+ break;
+ }
+
switch (r_type)
{
+ case R_PPC64_TLSGD:
+ case R_PPC64_TLSLD:
+ /* These special tls relocs tie a call to __tls_get_addr with
+ its parameter symbol. */
+ break;
+
case R_PPC64_GOT_TLSLD16:
case R_PPC64_GOT_TLSLD16_LO:
case R_PPC64_GOT_TLSLD16_HI:
case R_PPC64_GOT_TPREL16_LO_DS:
case R_PPC64_GOT_TPREL16_HI:
case R_PPC64_GOT_TPREL16_HA:
- if (info->shared)
+ if (!info->executable)
info->flags |= DF_STATIC_TLS;
tls_type = TLS_TLS | TLS_TPREL;
goto dogottls;
if (!update_plt_info (abfd, (struct ppc_link_hash_entry *) h,
rel->r_addend))
return FALSE;
- if (h == &htab->tls_get_addr->elf
- || h == &htab->tls_get_addr_fd->elf)
+ if (h == tga || h == dottga)
sec->has_tls_reloc = 1;
- else if (htab->tls_get_addr == NULL
- && CONST_STRNEQ (h->root.root.string, ".__tls_get_addr")
- && (h->root.root.string[15] == 0
- || h->root.root.string[15] == '@'))
- {
- htab->tls_get_addr = (struct ppc_link_hash_entry *) h;
- sec->has_tls_reloc = 1;
- }
- else if (htab->tls_get_addr_fd == NULL
- && CONST_STRNEQ (h->root.root.string, "__tls_get_addr")
- && (h->root.root.string[14] == 0
- || h->root.root.string[14] == '@'))
- {
- htab->tls_get_addr_fd = (struct ppc_link_hash_entry *) h;
- sec->has_tls_reloc = 1;
- }
}
break;
case R_PPC64_TPREL64:
tls_type = TLS_EXPLICIT | TLS_TLS | TLS_TPREL;
- if (info->shared)
+ if (!info->executable)
info->flags |= DF_STATIC_TLS;
goto dotlstoc;
ppc64_sec = ppc64_elf_section_data (sec);
if (ppc64_sec->sec_type != sec_toc)
{
+ bfd_size_type amt;
+
/* One extra to simplify get_tls_mask. */
- bfd_size_type amt = sec->size * sizeof (unsigned) / 8 + 1;
- ppc64_sec->u.t_symndx = bfd_zalloc (abfd, amt);
- if (ppc64_sec->u.t_symndx == NULL)
+ amt = sec->size * sizeof (unsigned) / 8 + sizeof (unsigned);
+ ppc64_sec->u.toc.symndx = bfd_zalloc (abfd, amt);
+ if (ppc64_sec->u.toc.symndx == NULL)
+ return FALSE;
+ amt = sec->size * sizeof (bfd_vma) / 8;
+ ppc64_sec->u.toc.add = bfd_zalloc (abfd, amt);
+ if (ppc64_sec->u.toc.add == NULL)
return FALSE;
BFD_ASSERT (ppc64_sec->sec_type == sec_normal);
ppc64_sec->sec_type = sec_toc;
}
BFD_ASSERT (rel->r_offset % 8 == 0);
- ppc64_sec->u.t_symndx[rel->r_offset / 8] = r_symndx;
+ ppc64_sec->u.toc.symndx[rel->r_offset / 8] = r_symndx;
+ ppc64_sec->u.toc.add[rel->r_offset / 8] = rel->r_addend;
/* Mark the second slot of a GD or LD entry.
-1 to indicate GD and -2 to indicate LD. */
if (tls_type == (TLS_EXPLICIT | TLS_TLS | TLS_GD))
- ppc64_sec->u.t_symndx[rel->r_offset / 8 + 1] = -1;
+ ppc64_sec->u.toc.symndx[rel->r_offset / 8 + 1] = -1;
else if (tls_type == (TLS_EXPLICIT | TLS_TLS | TLS_LD))
- ppc64_sec->u.t_symndx[rel->r_offset / 8 + 1] = -2;
+ ppc64_sec->u.toc.symndx[rel->r_offset / 8 + 1] = -2;
goto dodyn;
case R_PPC64_TPREL16:
case R_PPC64_TPREL16_HIGHESTA:
if (info->shared)
{
- info->flags |= DF_STATIC_TLS;
+ if (!info->executable)
+ info->flags |= DF_STATIC_TLS;
goto dodyn;
}
break;
symbol. */
dodyn:
if ((info->shared
- && (MUST_BE_DYN_RELOC (r_type)
+ && (must_be_dyn_reloc (info, r_type)
|| (h != NULL
&& (! info->symbolic
|| h->root.type == bfd_link_hash_defweak
this reloc. */
if (sreloc == NULL)
{
- const char *name;
- bfd *dynobj;
-
- name = (bfd_elf_string_from_elf_section
- (abfd,
- elf_elfheader (abfd)->e_shstrndx,
- elf_section_data (sec)->rel_hdr.sh_name));
- if (name == NULL)
- return FALSE;
+ sreloc = _bfd_elf_make_dynamic_reloc_section
+ (sec, htab->elf.dynobj, 3, abfd, /*rela?*/ TRUE);
- if (! CONST_STRNEQ (name, ".rela")
- || strcmp (bfd_get_section_name (abfd, sec),
- name + 5) != 0)
- {
- (*_bfd_error_handler)
- (_("%B: bad relocation section name `%s\'"),
- abfd, name);
- bfd_set_error (bfd_error_bad_value);
- }
-
- dynobj = htab->elf.dynobj;
- sreloc = bfd_get_section_by_name (dynobj, name);
if (sreloc == NULL)
- {
- flagword flags;
-
- flags = (SEC_HAS_CONTENTS | SEC_READONLY
- | SEC_IN_MEMORY | SEC_LINKER_CREATED
- | SEC_ALLOC | SEC_LOAD);
- sreloc = bfd_make_section_with_flags (dynobj,
- name,
- flags);
- if (sreloc == NULL
- || ! bfd_set_section_alignment (dynobj, sreloc, 3))
- return FALSE;
- }
- elf_section_data (sec)->sreloc = sreloc;
+ return FALSE;
}
/* If this is a global symbol, we count the number of
}
p->count += 1;
- if (!MUST_BE_DYN_RELOC (r_type))
+ if (!must_be_dyn_reloc (info, r_type))
p->pc_count += 1;
}
break;
return val;
}
+ BFD_ASSERT (is_ppc64_elf (opd_bfd));
+
relocs = ppc64_elf_tdata (opd_bfd)->opd_relocs;
if (relocs == NULL)
relocs = _bfd_elf_link_read_relocs (opd_bfd, opd_sec, NULL, NULL, TRUE);
hi = look;
else
{
- Elf_Internal_Shdr *symtab_hdr = &elf_tdata (opd_bfd)->symtab_hdr;
+ Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (opd_bfd);
+
if (ELF64_R_TYPE (look->r_info) == R_PPC64_ADDR64
&& ELF64_R_TYPE ((look + 1)->r_info) == R_PPC64_TOC)
{
sym += symndx;
val = sym->st_value;
- sec = NULL;
- if ((sym->st_shndx != SHN_UNDEF
- && sym->st_shndx < SHN_LORESERVE)
- || sym->st_shndx > SHN_HIRESERVE)
- sec = bfd_section_from_elf_index (opd_bfd, sym->st_shndx);
+ sec = bfd_section_from_elf_index (opd_bfd, sym->st_shndx);
BFD_ASSERT ((sec->flags & SEC_MERGE) == 0);
}
else
elf_section_data (sec)->local_dynrel = NULL;
htab = ppc_hash_table (info);
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
local_got_ents = elf_local_got_ents (abfd);
fdh = (struct ppc_link_hash_entry *) fdh->elf.root.u.i.link;
if (fdh == NULL
- && info->shared
+ && !info->executable
&& (fh->elf.root.type == bfd_link_hash_undefined
|| fh->elf.root.type == bfd_link_hash_undefweak))
{
if (fdh != NULL
&& !fdh->elf.forced_local
- && (info->shared
+ && (!info->executable
|| fdh->elf.def_dynamic
|| fdh->elf.ref_dynamic
|| (fdh->elf.root.type == bfd_link_hash_undefweak
unsigned long r_symndx,
bfd *ibfd)
{
- Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (ibfd);
if (r_symndx >= symtab_hdr->sh_info)
{
*symp = sym;
if (symsecp != NULL)
- {
- asection *symsec = NULL;
- if ((sym->st_shndx != SHN_UNDEF
- && sym->st_shndx < SHN_LORESERVE)
- || sym->st_shndx > SHN_HIRESERVE)
- symsec = bfd_section_from_elf_index (ibfd, sym->st_shndx);
- *symsecp = symsec;
- }
+ *symsecp = bfd_section_from_elf_index (ibfd, sym->st_shndx);
if (tls_maskp != NULL)
{
type suitable for optimization, and 1 otherwise. */
static int
-get_tls_mask (char **tls_maskp, unsigned long *toc_symndx,
+get_tls_mask (char **tls_maskp,
+ unsigned long *toc_symndx,
+ bfd_vma *toc_addend,
Elf_Internal_Sym **locsymsp,
- const Elf_Internal_Rela *rel, bfd *ibfd)
+ const Elf_Internal_Rela *rel,
+ bfd *ibfd)
{
unsigned long r_symndx;
int next_r;
off = sym->st_value;
off += rel->r_addend;
BFD_ASSERT (off % 8 == 0);
- r_symndx = ppc64_elf_section_data (sec)->u.t_symndx[off / 8];
- next_r = ppc64_elf_section_data (sec)->u.t_symndx[off / 8 + 1];
- if (!get_sym_h (&h, &sym, &sec, tls_maskp, locsymsp, r_symndx, ibfd))
- return 0;
+ r_symndx = ppc64_elf_section_data (sec)->u.toc.symndx[off / 8];
+ next_r = ppc64_elf_section_data (sec)->u.toc.symndx[off / 8 + 1];
if (toc_symndx != NULL)
*toc_symndx = r_symndx;
+ if (toc_addend != NULL)
+ *toc_addend = ppc64_elf_section_data (sec)->u.toc.add[off / 8];
+ if (!get_sym_h (&h, &sym, &sec, tls_maskp, locsymsp, r_symndx, ibfd))
+ return 0;
if ((h == NULL
|| ((h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak)
}
if ((info->shared
- && (MUST_BE_DYN_RELOC (r_type)
+ && (must_be_dyn_reloc (info, r_type)
|| (h != NULL
&& (!info->symbolic
|| h->root.type == bfd_link_hash_defweak
{
if (p->sec == sec)
{
- if (!MUST_BE_DYN_RELOC (r_type))
+ if (!must_be_dyn_reloc (info, r_type))
p->pc_count -= 1;
p->count -= 1;
if (p->count == 0)
continue;
local_syms = NULL;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
sym_hashes = elf_sym_hashes (ibfd);
/* Read the relocations. */
struct ppc_link_hash_table *htab;
htab = ppc_hash_table (info);
- if (htab->tls_get_addr != NULL)
- {
- struct ppc_link_hash_entry *h = htab->tls_get_addr;
-
- while (h->elf.root.type == bfd_link_hash_indirect
- || h->elf.root.type == bfd_link_hash_warning)
- h = (struct ppc_link_hash_entry *) h->elf.root.u.i.link;
-
- htab->tls_get_addr = h;
+ htab->tls_get_addr = ((struct ppc_link_hash_entry *)
+ elf_link_hash_lookup (&htab->elf, ".__tls_get_addr",
+ FALSE, FALSE, TRUE));
+ htab->tls_get_addr_fd = ((struct ppc_link_hash_entry *)
+ elf_link_hash_lookup (&htab->elf, "__tls_get_addr",
+ FALSE, FALSE, TRUE));
+ return _bfd_elf_tls_setup (obfd, info);
+}
- if (htab->tls_get_addr_fd == NULL
- && h->oh != NULL
- && h->oh->is_func_descriptor
- && (h->oh->elf.root.type == bfd_link_hash_defined
- || h->oh->elf.root.type == bfd_link_hash_defweak))
- htab->tls_get_addr_fd = h->oh;
- }
+/* Return TRUE iff REL is a branch reloc with a global symbol matching
+ HASH1 or HASH2. */
- if (htab->tls_get_addr_fd != NULL)
+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)
+{
+ Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (ibfd);
+ enum elf_ppc64_reloc_type r_type = ELF64_R_TYPE (rel->r_info);
+ unsigned int r_symndx = ELF64_R_SYM (rel->r_info);
+
+ if (r_symndx >= symtab_hdr->sh_info
+ && (r_type == R_PPC64_REL24
+ || r_type == R_PPC64_REL14
+ || r_type == R_PPC64_REL14_BRTAKEN
+ || r_type == R_PPC64_REL14_BRNTAKEN
+ || r_type == R_PPC64_ADDR24
+ || r_type == R_PPC64_ADDR14
+ || r_type == R_PPC64_ADDR14_BRTAKEN
+ || r_type == R_PPC64_ADDR14_BRNTAKEN))
{
- struct ppc_link_hash_entry *h = htab->tls_get_addr_fd;
-
- while (h->elf.root.type == bfd_link_hash_indirect
- || h->elf.root.type == bfd_link_hash_warning)
- h = (struct ppc_link_hash_entry *) h->elf.root.u.i.link;
+ struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (ibfd);
+ struct elf_link_hash_entry *h;
- htab->tls_get_addr_fd = h;
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ if (h == &hash1->elf || h == &hash2->elf)
+ return TRUE;
}
-
- return _bfd_elf_tls_setup (obfd, info);
+ return FALSE;
}
/* Run through all the TLS relocs looking for optimization
struct ppc_link_hash_table *htab;
int pass;
- if (info->relocatable || info->shared)
+ if (info->relocatable || !info->executable)
return TRUE;
htab = ppc_hash_table (info);
if (toc_ref != NULL)
free (toc_ref);
if (locsyms != NULL
- && (elf_tdata (ibfd)->symtab_hdr.contents
+ && (elf_symtab_hdr (ibfd).contents
!= (unsigned char *) locsyms))
free (locsyms);
return FALSE;
case R_PPC64_TOC16:
case R_PPC64_TOC16_LO:
case R_PPC64_TLS:
+ case R_PPC64_TLSGD:
+ case R_PPC64_TLSLD:
if (sym_sec == NULL || sym_sec != toc)
continue;
value += rel->r_addend;
BFD_ASSERT (value < toc->size && value % 8 == 0);
toc_ref_index = value / 8;
- if (r_type == R_PPC64_TLS)
+ if (r_type == R_PPC64_TLS
+ || r_type == R_PPC64_TLSGD
+ || r_type == R_PPC64_TLSLD)
{
toc_ref[toc_ref_index] = 1;
continue;
if (pass == 0)
{
- if (!expecting_tls_get_addr)
+ if (!expecting_tls_get_addr
+ || !sec->has_tls_get_addr_call)
continue;
- if (rel + 1 < relend)
+ if (rel + 1 < relend
+ && branch_reloc_hash_match (ibfd, rel + 1,
+ htab->tls_get_addr,
+ htab->tls_get_addr_fd))
{
- Elf_Internal_Shdr *symtab_hdr;
- enum elf_ppc64_reloc_type r_type2;
- unsigned long r_symndx2;
- struct elf_link_hash_entry *h2;
-
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
-
- /* The next instruction should be a call to
- __tls_get_addr. Peek at the reloc to be sure. */
- r_type2 = ELF64_R_TYPE (rel[1].r_info);
- r_symndx2 = ELF64_R_SYM (rel[1].r_info);
- if (r_symndx2 >= symtab_hdr->sh_info
- && (r_type2 == R_PPC64_REL14
- || r_type2 == R_PPC64_REL14_BRTAKEN
- || r_type2 == R_PPC64_REL14_BRNTAKEN
- || r_type2 == R_PPC64_REL24))
+ if (expecting_tls_get_addr == 2)
{
- struct elf_link_hash_entry **sym_hashes;
-
- sym_hashes = elf_sym_hashes (ibfd);
-
- h2 = sym_hashes[r_symndx2 - symtab_hdr->sh_info];
- while (h2->root.type == bfd_link_hash_indirect
- || h2->root.type == bfd_link_hash_warning)
- h2 = ((struct elf_link_hash_entry *)
- h2->root.u.i.link);
- if (h2 != NULL
- && (h2 == &htab->tls_get_addr->elf
- || h2 == &htab->tls_get_addr_fd->elf))
- {
- if (expecting_tls_get_addr == 2)
- {
- /* Check for toc tls entries. */
- char *toc_tls;
- int retval;
-
- retval = get_tls_mask (&toc_tls, NULL,
- &locsyms,
- rel, ibfd);
- if (retval == 0)
- goto err_free_rel;
- if (retval > 1 && toc_tls != NULL)
- toc_ref[toc_ref_index] = 1;
- }
- continue;
- }
+ /* Check for toc tls entries. */
+ char *toc_tls;
+ int retval;
+
+ retval = get_tls_mask (&toc_tls, NULL, NULL,
+ &locsyms,
+ rel, ibfd);
+ if (retval == 0)
+ goto err_free_rel;
+ if (retval > 1 && toc_tls != NULL)
+ toc_ref[toc_ref_index] = 1;
}
+ continue;
}
if (expecting_tls_get_addr != 1)
break;
}
- if (expecting_tls_get_addr)
+ if (expecting_tls_get_addr && htab->tls_get_addr != NULL)
{
struct plt_entry *ent;
for (ent = htab->tls_get_addr->elf.plt.plist;
}
}
- if (expecting_tls_get_addr)
+ if (expecting_tls_get_addr && htab->tls_get_addr_fd != NULL)
{
struct plt_entry *ent;
for (ent = htab->tls_get_addr_fd->elf.plt.plist;
free (relstart);
}
- if (toc_ref != NULL)
- free (toc_ref);
+ if (toc_ref != NULL)
+ free (toc_ref);
- if (locsyms != NULL
- && (elf_tdata (ibfd)->symtab_hdr.contents
- != (unsigned char *) locsyms))
- {
- if (!info->keep_memory)
- free (locsyms);
- else
- elf_tdata (ibfd)->symtab_hdr.contents = (unsigned char *) locsyms;
- }
- }
+ if (locsyms != NULL
+ && (elf_symtab_hdr (ibfd).contents != (unsigned char *) locsyms))
+ {
+ if (!info->keep_memory)
+ free (locsyms);
+ else
+ elf_symtab_hdr (ibfd).contents = (unsigned char *) locsyms;
+ }
+ }
return TRUE;
}
continue;
local_syms = NULL;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
sym_hashes = elf_sym_hashes (ibfd);
/* Look at sections dropped from the final link. */
for (sym = local_syms;
sym < local_syms + symtab_hdr->sh_info;
++sym)
- if (sym->st_shndx != SHN_UNDEF
- && (sym->st_shndx < SHN_LORESERVE
- || sym->st_shndx > SHN_HIRESERVE)
- && sym->st_value != 0
+ if (sym->st_value != 0
&& bfd_section_from_elf_index (ibfd, sym->st_shndx) == toc)
{
if (skip[sym->st_value >> 3] != (unsigned long) -1)
Undefined weak syms won't yet be marked as dynamic,
nor will all TLS symbols. */
if (h->dynindx == -1
- && !h->forced_local)
+ && !h->forced_local
+ && htab->elf.dynamic_sections_created)
{
if (! bfd_elf_link_record_dynamic_symbol (info, h))
return FALSE;
continue;
}
+ if (!is_ppc64_elf (gent->owner))
+ continue;
+
s = ppc64_elf_tdata (gent->owner)->got;
gent->got.offset = s->size;
s->size
else
gent->got.offset = (bfd_vma) -1;
- if (eh->dyn_relocs == NULL)
+ if (eh->dyn_relocs == NULL
+ || !htab->elf.dynamic_sections_created)
return TRUE;
/* In the shared -Bsymbolic case, discard space allocated for
if (info->shared)
{
/* Relocs that use pc_count are those that appear on a call insn,
- or certain REL relocs (see MUST_BE_DYN_RELOC) that can be
+ or certain REL relocs (see must_be_dyn_reloc) that can be
generated via assembly. We want calls to protected symbols to
resolve directly to the function rather than going via the plt.
If people want function pointer comparisons to work as expected
dynamic. */
if (!h->non_got_ref
- && h->def_dynamic
&& !h->def_regular)
{
/* Make sure this symbol is output as a dynamic symbol.
Elf_Internal_Shdr *symtab_hdr;
asection *srel;
- if (!is_ppc64_elf_target (ibfd->xvec))
+ if (!is_ppc64_elf (ibfd))
continue;
for (s = ibfd->sections; s != NULL; s = s->next)
if (!lgot_ents)
continue;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
locsymcount = symtab_hdr->sh_info;
end_lgot_ents = lgot_ents + locsymcount;
lgot_masks = (char *) end_lgot_ents;
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
{
- if (!is_ppc64_elf_target (ibfd->xvec))
+ if (!is_ppc64_elf (ibfd))
continue;
if (ppc64_tlsld_got (ibfd)->refcount > 0)
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
{
- if (!is_ppc64_elf_target (ibfd->xvec))
+ if (!is_ppc64_elf (ibfd))
continue;
s = ppc64_elf_tdata (ibfd)->got;
/* Build a .plt call stub. */
static inline bfd_byte *
-build_plt_stub (bfd *obfd, bfd_byte *p, int offset)
+build_plt_stub (bfd *obfd, bfd_byte *p, int offset, Elf_Internal_Rela *r)
{
#define PPC_LO(v) ((v) & 0xffff)
#define PPC_HI(v) (((v) >> 16) & 0xffff)
if (PPC_HA (offset) != 0)
{
+ if (r != NULL)
+ {
+ r[0].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_HA);
+ r[1].r_offset = r[0].r_offset + 8;
+ r[1].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_LO_DS);
+ r[1].r_addend = r[0].r_addend;
+ if (PPC_HA (offset + 16) != PPC_HA (offset))
+ {
+ r[2].r_offset = r[1].r_offset + 4;
+ r[2].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_LO);
+ r[2].r_addend = r[0].r_addend;
+ }
+ else
+ {
+ r[2].r_offset = r[1].r_offset + 8;
+ r[2].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_LO_DS);
+ r[2].r_addend = r[0].r_addend + 8;
+ r[3].r_offset = r[2].r_offset + 4;
+ r[3].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_LO_DS);
+ r[3].r_addend = r[0].r_addend + 16;
+ }
+ }
bfd_put_32 (obfd, ADDIS_R12_R2 | PPC_HA (offset), p), p += 4;
bfd_put_32 (obfd, STD_R2_40R1, p), p += 4;
bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset), p), p += 4;
}
else
{
+ if (r != NULL)
+ {
+ r[0].r_offset += 4;
+ r[0].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_DS);
+ if (PPC_HA (offset + 16) != PPC_HA (offset))
+ {
+ r[1].r_offset = r[0].r_offset + 4;
+ r[1].r_info = ELF64_R_INFO (0, R_PPC64_TOC16);
+ r[1].r_addend = r[0].r_addend;
+ }
+ else
+ {
+ r[1].r_offset = r[0].r_offset + 8;
+ r[1].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_DS);
+ r[1].r_addend = r[0].r_addend + 16;
+ r[2].r_offset = r[1].r_offset + 4;
+ r[2].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_DS);
+ r[2].r_addend = r[0].r_addend + 8;
+ }
+ }
bfd_put_32 (obfd, STD_R2_40R1, p), p += 4;
bfd_put_32 (obfd, LD_R11_0R2 | PPC_LO (offset), p), p += 4;
if (PPC_HA (offset + 16) != PPC_HA (offset))
return p;
}
+static Elf_Internal_Rela *
+get_relocs (asection *sec, int count)
+{
+ Elf_Internal_Rela *relocs;
+ struct bfd_elf_section_data *elfsec_data;
+
+ elfsec_data = elf_section_data (sec);
+ relocs = elfsec_data->relocs;
+ if (relocs == NULL)
+ {
+ bfd_size_type relsize;
+ relsize = sec->reloc_count * sizeof (*relocs);
+ relocs = bfd_alloc (sec->owner, relsize);
+ if (relocs == NULL)
+ return NULL;
+ elfsec_data->relocs = relocs;
+ elfsec_data->rel_hdr.sh_size = (sec->reloc_count
+ * sizeof (Elf64_External_Rela));
+ elfsec_data->rel_hdr.sh_entsize = sizeof (Elf64_External_Rela);
+ sec->reloc_count = 0;
+ }
+ relocs += sec->reloc_count;
+ sec->reloc_count += count;
+ return relocs;
+}
+
static bfd_boolean
ppc_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
{
struct ppc_link_hash_table *htab;
bfd_byte *loc;
bfd_byte *p;
- unsigned int indx;
struct plt_entry *ent;
bfd_vma dest, off;
int size;
+ Elf_Internal_Rela *r;
/* Massage our args to the form they really have. */
stub_entry = (struct ppc_stub_hash_entry *) gen_entry;
if (info->emitrelocations)
{
- Elf_Internal_Rela *relocs, *r;
- struct bfd_elf_section_data *elfsec_data;
-
- elfsec_data = elf_section_data (stub_entry->stub_sec);
- relocs = elfsec_data->relocs;
- if (relocs == NULL)
- {
- bfd_size_type relsize;
- relsize = stub_entry->stub_sec->reloc_count * sizeof (*relocs);
- relocs = bfd_alloc (htab->stub_bfd, relsize);
- if (relocs == NULL)
- return FALSE;
- elfsec_data->relocs = relocs;
- elfsec_data->rel_hdr.sh_size = (stub_entry->stub_sec->reloc_count
- * sizeof (Elf64_External_Rela));
- elfsec_data->rel_hdr.sh_entsize = sizeof (Elf64_External_Rela);
- stub_entry->stub_sec->reloc_count = 0;
- }
- r = relocs + stub_entry->stub_sec->reloc_count;
- stub_entry->stub_sec->reloc_count += 1;
+ r = get_relocs (stub_entry->stub_sec, 1);
+ if (r == NULL)
+ return FALSE;
r->r_offset = loc - stub_entry->stub_sec->contents;
r->r_info = ELF64_R_INFO (0, R_PPC64_REL24);
r->r_addend = dest;
return FALSE;
}
- off = (stub_entry->target_value
- + stub_entry->target_section->output_offset
- + stub_entry->target_section->output_section->vma);
+ dest = (stub_entry->target_value
+ + stub_entry->target_section->output_offset
+ + stub_entry->target_section->output_section->vma);
- bfd_put_64 (htab->brlt->owner, off,
+ bfd_put_64 (htab->brlt->owner, dest,
htab->brlt->contents + br_entry->offset);
if (br_entry->iter == htab->stub_iteration)
+ htab->brlt->output_offset
+ htab->brlt->output_section->vma);
rela.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE);
- rela.r_addend = off;
+ rela.r_addend = dest;
rl = htab->relbrlt->contents;
rl += (htab->relbrlt->reloc_count++
}
else if (info->emitrelocations)
{
- Elf_Internal_Rela *relocs, *r;
- struct bfd_elf_section_data *elfsec_data;
-
- elfsec_data = elf_section_data (htab->brlt);
- relocs = elfsec_data->relocs;
- if (relocs == NULL)
- {
- bfd_size_type relsize;
- relsize = htab->brlt->reloc_count * sizeof (*relocs);
- relocs = bfd_alloc (htab->brlt->owner, relsize);
- if (relocs == NULL)
- return FALSE;
- elfsec_data->relocs = relocs;
- elfsec_data->rel_hdr.sh_size
- = (stub_entry->stub_sec->reloc_count
- * sizeof (Elf64_External_Rela));
- elfsec_data->rel_hdr.sh_entsize
- = sizeof (Elf64_External_Rela);
- htab->brlt->reloc_count = 0;
- }
- r = relocs + htab->brlt->reloc_count;
- htab->brlt->reloc_count += 1;
+ r = get_relocs (htab->brlt, 1);
+ if (r == NULL)
+ return FALSE;
+ /* brlt, being SEC_LINKER_CREATED does not go through the
+ normal reloc processing. Symbols and offsets are not
+ translated from input file to output file form, so
+ set up the offset per the output file. */
r->r_offset = (br_entry->offset
+ htab->brlt->output_offset
+ htab->brlt->output_section->vma);
r->r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE);
- r->r_addend = off;
+ r->r_addend = dest;
}
}
- off = (br_entry->offset
- + htab->brlt->output_offset
- + htab->brlt->output_section->vma
+ dest = (br_entry->offset
+ + htab->brlt->output_offset
+ + htab->brlt->output_section->vma);
+
+ off = (dest
- elf_gp (htab->brlt->output_section->owner)
- htab->stub_group[stub_entry->id_sec->id].toc_off);
return FALSE;
}
- indx = off;
+ if (info->emitrelocations)
+ {
+ r = get_relocs (stub_entry->stub_sec, 1 + (PPC_HA (off) != 0));
+ if (r == NULL)
+ return FALSE;
+ r[0].r_offset = loc - stub_entry->stub_sec->contents;
+ if (bfd_big_endian (info->output_bfd))
+ r[0].r_offset += 2;
+ if (stub_entry->stub_type == ppc_stub_plt_branch_r2off)
+ r[0].r_offset += 4;
+ r[0].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_DS);
+ r[0].r_addend = dest;
+ if (PPC_HA (off) != 0)
+ {
+ r[0].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_HA);
+ r[1].r_offset = r[0].r_offset + 4;
+ r[1].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_LO_DS);
+ r[1].r_addend = r[0].r_addend;
+ }
+ }
+
if (stub_entry->stub_type != ppc_stub_plt_branch_r2off)
{
- if (PPC_HA (indx) != 0)
+ if (PPC_HA (off) != 0)
{
size = 16;
- bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (indx), loc);
+ bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (off), loc);
loc += 4;
- bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (indx), loc);
+ bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (off), loc);
}
else
{
size = 12;
- bfd_put_32 (htab->stub_bfd, LD_R11_0R2 | PPC_LO (indx), loc);
+ bfd_put_32 (htab->stub_bfd, LD_R11_0R2 | PPC_LO (off), loc);
}
}
else
bfd_put_32 (htab->stub_bfd, STD_R2_40R1, loc);
loc += 4;
size = 20;
- if (PPC_HA (indx) != 0)
+ if (PPC_HA (off) != 0)
{
size += 4;
- bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (indx), loc);
+ bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (off), loc);
loc += 4;
- bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (indx), loc);
+ bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (off), loc);
loc += 4;
}
else
{
- bfd_put_32 (htab->stub_bfd, LD_R11_0R2 | PPC_LO (indx), loc);
+ bfd_put_32 (htab->stub_bfd, LD_R11_0R2 | PPC_LO (off), loc);
loc += 4;
}
}
/* Now build the stub. */
- off = (bfd_vma) -1;
+ dest = (bfd_vma) -1;
for (ent = stub_entry->h->elf.plt.plist; ent != NULL; ent = ent->next)
if (ent->addend == stub_entry->addend)
{
- off = ent->plt.offset;
+ dest = ent->plt.offset;
break;
}
- if (off >= (bfd_vma) -2)
+ if (dest >= (bfd_vma) -2)
abort ();
- off &= ~ (bfd_vma) 1;
- off += (htab->plt->output_offset
- + htab->plt->output_section->vma
- - elf_gp (htab->plt->output_section->owner)
- - htab->stub_group[stub_entry->id_sec->id].toc_off);
+ dest &= ~ (bfd_vma) 1;
+ dest += (htab->plt->output_offset
+ + htab->plt->output_section->vma);
+
+ off = (dest
+ - elf_gp (htab->plt->output_section->owner)
+ - htab->stub_group[stub_entry->id_sec->id].toc_off);
if (off + 0x80008000 > 0xffffffff || (off & 7) != 0)
{
return FALSE;
}
- p = build_plt_stub (htab->stub_bfd, loc, off);
+ r = NULL;
+ if (info->emitrelocations)
+ {
+ r = get_relocs (stub_entry->stub_sec,
+ (2 + (PPC_HA (off) != 0)
+ + (PPC_HA (off + 16) == PPC_HA (off))));
+ if (r == NULL)
+ return FALSE;
+ r[0].r_offset = loc - stub_entry->stub_sec->contents;
+ if (bfd_big_endian (info->output_bfd))
+ r[0].r_offset += 2;
+ r[0].r_addend = dest;
+ }
+ p = build_plt_stub (htab->stub_bfd, loc, off, r);
size = p - loc;
break;
size -= 4;
if (PPC_HA (off + 16) != PPC_HA (off))
size += 4;
+ if (info->emitrelocations)
+ {
+ stub_entry->stub_sec->reloc_count
+ += 2 + (PPC_HA (off) != 0) + (PPC_HA (off + 16) == PPC_HA (off));
+ stub_entry->stub_sec->flags |= SEC_RELOC;
+ }
}
else
{
if (off + (1 << 25) >= (bfd_vma) (1 << 26))
{
struct ppc_branch_hash_entry *br_entry;
- unsigned int indx;
br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table,
stub_entry->root.string + 9,
- elf_gp (htab->brlt->output_section->owner)
- htab->stub_group[stub_entry->id_sec->id].toc_off);
- indx = off;
+ if (info->emitrelocations)
+ {
+ stub_entry->stub_sec->reloc_count += 1 + (PPC_HA (off) != 0);
+ stub_entry->stub_sec->flags |= SEC_RELOC;
+ }
+
if (stub_entry->stub_type != ppc_stub_plt_branch_r2off)
{
size = 12;
- if (PPC_HA (indx) != 0)
+ if (PPC_HA (off) != 0)
size = 16;
}
else
{
size = 20;
- if (PPC_HA (indx) != 0)
+ if (PPC_HA (off) != 0)
size += 4;
if (PPC_HA (r2off) != 0)
enum elf_ppc64_reloc_type r_type;
unsigned long r_symndx;
struct elf_link_hash_entry *h;
+ struct ppc_link_hash_entry *eh;
Elf_Internal_Sym *sym;
asection *sym_sec;
struct _opd_sec_data *opd;
}
/* Calls to dynamic lib functions go through a plt call stub
- that uses r2. Branches to undefined symbols might be a call
- using old-style dot symbols that can be satisfied by a plt
- call into a new-style dynamic library. */
- if (sym_sec == NULL)
+ that uses r2. */
+ eh = (struct ppc_link_hash_entry *) h;
+ if (eh != NULL
+ && (eh->elf.plt.plist != NULL
+ || (eh->oh != NULL
+ && eh->oh->elf.plt.plist != NULL)))
{
- struct ppc_link_hash_entry *eh = (struct ppc_link_hash_entry *) h;
- if (eh != NULL
- && eh->oh != NULL
- && eh->oh->elf.plt.plist != NULL)
- {
- ret = 1;
- break;
- }
-
- /* Ignore other undefined symbols. */
- continue;
+ ret = 1;
+ break;
}
+ if (sym_sec == NULL)
+ /* Ignore other undefined symbols. */
+ continue;
+
/* Assume branches to other sections not included in the link need
stubs too, to cover -R and absolute syms. */
if (sym_sec->output_section == NULL)
}
if (local_syms != NULL
- && (elf_tdata (isec->owner)->symtab_hdr.contents
- != (unsigned char *) local_syms))
+ && (elf_symtab_hdr (isec->owner).contents != (unsigned char *) local_syms))
free (local_syms);
if (elf_section_data (isec)->relocs != relstart)
free (relstart);
asection *section;
Elf_Internal_Sym *local_syms = NULL;
- if (!is_ppc64_elf_target (input_bfd->xvec))
+ if (!is_ppc64_elf (input_bfd))
continue;
/* We'll need the symbol table in a second. */
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (input_bfd);
if (symtab_hdr->sh_info == 0)
continue;
/* Get tls info. */
char *tls_mask;
- if (!get_tls_mask (&tls_mask, NULL, &local_syms,
+ if (!get_tls_mask (&tls_mask, NULL, NULL, &local_syms,
irela - 1, input_bfd))
goto error_ret_free_internal;
if (*tls_mask != 0)
bfd_hash_traverse (&htab->stub_hash_table, ppc_size_one_stub, info);
+ if (info->emitrelocations
+ && htab->glink != NULL && htab->glink->size != 0)
+ {
+ htab->glink->reloc_count = 1;
+ htab->glink->flags |= SEC_RELOC;
+ }
+
for (stub_sec = htab->stub_bfd->sections;
stub_sec != NULL;
stub_sec = stub_sec->next)
if (htab->emit_stub_syms)
{
struct elf_link_hash_entry *h;
- h = elf_link_hash_lookup (&htab->elf, "__glink", TRUE, FALSE, FALSE);
+ h = elf_link_hash_lookup (&htab->elf, "__glink_PLTresolve",
+ TRUE, FALSE, FALSE);
if (h == NULL)
return FALSE;
if (h->root.type == bfd_link_hash_new)
h->non_elf = 0;
}
}
+ plt0 = htab->plt->output_section->vma + htab->plt->output_offset - 16;
+ if (info->emitrelocations)
+ {
+ Elf_Internal_Rela *r = get_relocs (htab->glink, 1);
+ if (r == NULL)
+ return FALSE;
+ r->r_offset = (htab->glink->output_offset
+ + htab->glink->output_section->vma);
+ r->r_info = ELF64_R_INFO (0, R_PPC64_REL64);
+ r->r_addend = plt0;
+ }
p = htab->glink->contents;
- plt0 = (htab->plt->output_section->vma
- + htab->plt->output_offset
- - (htab->glink->output_section->vma
- + htab->glink->output_offset
- + 16));
+ plt0 -= htab->glink->output_section->vma + htab->glink->output_offset;
bfd_put_64 (htab->glink->owner, plt0, p);
p += 8;
bfd_put_32 (htab->glink->owner, MFLR_R12, p);
if (input_section->owner == htab->stub_bfd)
return TRUE;
+ BFD_ASSERT (is_ppc64_elf (input_bfd));
+
local_got_ents = elf_local_got_ents (input_bfd);
TOCstart = elf_gp (output_bfd);
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);
is_opd = ppc64_elf_section_data (input_section)->sec_type == sec_opd;
struct ppc_link_hash_entry *fdh;
const char *sym_name;
unsigned long r_symndx, toc_symndx;
+ bfd_vma toc_addend;
char tls_mask, tls_gd, tls_type;
char sym_type;
bfd_vma relocation;
tls_mask = 0;
tls_gd = 0;
toc_symndx = 0;
- if (IS_PPC64_TLS_RELOC (r_type))
+ if (h != NULL)
+ tls_mask = h->tls_mask;
+ else if (local_got_ents != NULL)
{
- if (h != NULL)
- tls_mask = h->tls_mask;
- else if (local_got_ents != NULL)
- {
- char *lgot_masks;
- lgot_masks = (char *) (local_got_ents + symtab_hdr->sh_info);
- tls_mask = lgot_masks[r_symndx];
- }
- if (tls_mask == 0 && r_type == R_PPC64_TLS)
- {
- /* Check for toc tls entries. */
- char *toc_tls;
+ char *lgot_masks;
+ lgot_masks = (char *) (local_got_ents + symtab_hdr->sh_info);
+ tls_mask = lgot_masks[r_symndx];
+ }
+ if (tls_mask == 0
+ && (r_type == R_PPC64_TLS
+ || r_type == R_PPC64_TLSGD
+ || r_type == R_PPC64_TLSLD))
+ {
+ /* Check for toc tls entries. */
+ char *toc_tls;
- if (!get_tls_mask (&toc_tls, &toc_symndx, &local_syms,
- rel, input_bfd))
- return FALSE;
+ if (!get_tls_mask (&toc_tls, &toc_symndx, &toc_addend,
+ &local_syms, rel, input_bfd))
+ return FALSE;
- if (toc_tls)
- tls_mask = *toc_tls;
- }
+ if (toc_tls)
+ tls_mask = *toc_tls;
}
/* Check that tls relocs are used with tls syms, and non-tls
&& (h == NULL
|| h->elf.root.type == bfd_link_hash_defined
|| h->elf.root.type == bfd_link_hash_defweak)
- && IS_PPC64_TLS_RELOC (r_type) != (sym_type == STT_TLS))
+ && (IS_PPC64_TLS_RELOC (r_type)
+ != (sym_type == STT_TLS
+ || (sym_type == STT_SECTION
+ && (sec->flags & SEC_THREAD_LOCAL) != 0))))
{
- if (r_type == R_PPC64_TLS && tls_mask != 0)
+ if (tls_mask != 0
+ && (r_type == R_PPC64_TLS
+ || r_type == R_PPC64_TLSGD
+ || r_type == R_PPC64_TLSLD))
/* R_PPC64_TLS is OK against a symbol in the TOC. */
;
else
(*_bfd_error_handler)
- (sym_type == STT_TLS
+ (!IS_PPC64_TLS_RELOC (r_type)
? _("%B(%A+0x%lx): %s used with TLS symbol %s")
: _("%B(%A+0x%lx): %s used with non-TLS symbol %s"),
input_bfd,
char *toc_tls;
int retval;
- retval = get_tls_mask (&toc_tls, &toc_symndx, &local_syms,
- rel, input_bfd);
+ retval = get_tls_mask (&toc_tls, &toc_symndx, &toc_addend,
+ &local_syms, rel, input_bfd);
if (retval == 0)
return FALSE;
if (toc_symndx != 0)
{
rel->r_info = ELF64_R_INFO (toc_symndx, r_type);
+ rel->r_addend = toc_addend;
/* We changed the symbol. Start over in order to
get h, sym, sec etc. right. */
rel--;
if (toc_symndx != 0)
{
rel->r_info = ELF64_R_INFO (toc_symndx, r_type);
+ rel->r_addend = toc_addend;
/* We changed the symbol. Start over in order to
get h, sym, sec etc. right. */
rel--;
case R_PPC64_GOT_TLSLD16_LO:
if (tls_mask != 0 && (tls_mask & TLS_LD) == 0)
{
- bfd_vma insn1, insn2, insn3;
+ unsigned int insn1, insn2, insn3;
bfd_vma offset;
tls_ldgd_opt:
- /* We know that the next reloc is on a tls_get_addr
- call, since ppc64_elf_tls_optimize checks this. */
- offset = rel[1].r_offset;
- insn1 = bfd_get_32 (output_bfd,
- contents + rel->r_offset - d_offset);
- insn3 = bfd_get_32 (output_bfd,
- contents + offset + 4);
+ offset = (bfd_vma) -1;
+ /* If not using the newer R_PPC64_TLSGD/LD to mark
+ __tls_get_addr calls, we must trust that the call
+ stays with its arg setup insns, ie. that the next
+ reloc is the __tls_get_addr call associated with
+ the current reloc. Edit both insns. */
+ if (input_section->has_tls_get_addr_call
+ && rel + 1 < relend
+ && branch_reloc_hash_match (input_bfd, rel + 1,
+ htab->tls_get_addr,
+ htab->tls_get_addr_fd))
+ offset = rel[1].r_offset;
if ((tls_mask & tls_gd) != 0)
{
/* IE */
+ insn1 = bfd_get_32 (output_bfd,
+ contents + rel->r_offset - d_offset);
insn1 &= (1 << 26) - (1 << 2);
insn1 |= 58 << 26; /* ld */
insn2 = 0x7c636a14; /* add 3,3,13 */
- rel[1].r_info = ELF64_R_INFO (ELF64_R_SYM (rel[1].r_info),
- R_PPC64_NONE);
+ if (offset != (bfd_vma) -1)
+ rel[1].r_info = ELF64_R_INFO (ELF64_R_SYM (rel[1].r_info),
+ R_PPC64_NONE);
if ((tls_mask & TLS_EXPLICIT) == 0)
r_type = (((r_type - (R_PPC64_GOT_TLSGD16 & 3)) & 3)
+ R_PPC64_GOT_TPREL16_DS);
if (tls_gd == 0)
{
/* Was an LD reloc. */
- r_symndx = 0;
+ if (toc_symndx)
+ sec = local_sections[toc_symndx];
+ for (r_symndx = 0;
+ r_symndx < symtab_hdr->sh_info;
+ r_symndx++)
+ if (local_sections[r_symndx] == sec)
+ break;
+ if (r_symndx >= symtab_hdr->sh_info)
+ r_symndx = 0;
rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
- rel[1].r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
+ if (r_symndx != 0)
+ rel->r_addend -= (local_syms[r_symndx].st_value
+ + sec->output_offset
+ + sec->output_section->vma);
}
else if (toc_symndx != 0)
- r_symndx = toc_symndx;
+ {
+ r_symndx = toc_symndx;
+ rel->r_addend = toc_addend;
+ }
r_type = R_PPC64_TPREL16_HA;
rel->r_info = ELF64_R_INFO (r_symndx, r_type);
- rel[1].r_info = ELF64_R_INFO (r_symndx,
- R_PPC64_TPREL16_LO);
- rel[1].r_offset += d_offset;
+ if (offset != (bfd_vma) -1)
+ {
+ rel[1].r_info = ELF64_R_INFO (r_symndx,
+ R_PPC64_TPREL16_LO);
+ rel[1].r_offset = offset + d_offset;
+ rel[1].r_addend = rel->r_addend;
+ }
}
+ bfd_put_32 (output_bfd, insn1,
+ contents + rel->r_offset - d_offset);
+ if (offset != (bfd_vma) -1)
+ {
+ insn3 = bfd_get_32 (output_bfd,
+ contents + offset + 4);
+ if (insn3 == NOP
+ || insn3 == CROR_151515 || insn3 == CROR_313131)
+ {
+ rel[1].r_offset += 4;
+ bfd_put_32 (output_bfd, insn2, contents + offset + 4);
+ insn2 = NOP;
+ }
+ bfd_put_32 (output_bfd, insn2, contents + offset);
+ }
+ if ((tls_mask & tls_gd) == 0
+ && (tls_gd == 0 || toc_symndx != 0))
+ {
+ /* We changed the symbol. Start over in order
+ to get h, sym, sec etc. right. */
+ rel--;
+ continue;
+ }
+ }
+ break;
+
+ case R_PPC64_TLSGD:
+ if (tls_mask != 0 && (tls_mask & TLS_GD) == 0)
+ {
+ unsigned int insn2, insn3;
+ bfd_vma offset = rel->r_offset;
+
+ if ((tls_mask & TLS_TPRELGD) != 0)
+ {
+ /* IE */
+ r_type = R_PPC64_NONE;
+ insn2 = 0x7c636a14; /* add 3,3,13 */
+ }
+ else
+ {
+ /* LE */
+ if (toc_symndx != 0)
+ {
+ r_symndx = toc_symndx;
+ rel->r_addend = toc_addend;
+ }
+ r_type = R_PPC64_TPREL16_LO;
+ rel->r_offset = offset + d_offset;
+ insn2 = 0x38630000; /* addi 3,3,0 */
+ }
+ rel->r_info = ELF64_R_INFO (r_symndx, r_type);
+ /* Zap the reloc on the _tls_get_addr call too. */
+ BFD_ASSERT (offset == rel[1].r_offset);
+ rel[1].r_info = ELF64_R_INFO (ELF64_R_SYM (rel[1].r_info),
+ R_PPC64_NONE);
+ insn3 = bfd_get_32 (output_bfd,
+ contents + offset + 4);
if (insn3 == NOP
|| insn3 == CROR_151515 || insn3 == CROR_313131)
{
- insn3 = insn2;
+ rel->r_offset += 4;
+ bfd_put_32 (output_bfd, insn2, contents + offset + 4);
insn2 = NOP;
- rel[1].r_offset += 4;
}
- bfd_put_32 (output_bfd, insn1,
- contents + rel->r_offset - d_offset);
bfd_put_32 (output_bfd, insn2, contents + offset);
- bfd_put_32 (output_bfd, insn3, contents + offset + 4);
- if (tls_gd == 0 || toc_symndx != 0)
+ if ((tls_mask & TLS_TPRELGD) == 0 && toc_symndx != 0)
{
- /* We changed the symbol. Start over in order
- to get h, sym, sec etc. right. */
rel--;
continue;
}
}
break;
+ case R_PPC64_TLSLD:
+ if (tls_mask != 0 && (tls_mask & TLS_LD) == 0)
+ {
+ unsigned int insn2, insn3;
+ bfd_vma offset = rel->r_offset;
+
+ if (toc_symndx)
+ sec = local_sections[toc_symndx];
+ for (r_symndx = 0;
+ r_symndx < symtab_hdr->sh_info;
+ r_symndx++)
+ if (local_sections[r_symndx] == sec)
+ break;
+ if (r_symndx >= symtab_hdr->sh_info)
+ r_symndx = 0;
+ rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
+ if (r_symndx != 0)
+ rel->r_addend -= (local_syms[r_symndx].st_value
+ + sec->output_offset
+ + sec->output_section->vma);
+
+ r_type = R_PPC64_TPREL16_LO;
+ rel->r_info = ELF64_R_INFO (r_symndx, r_type);
+ rel->r_offset = offset + d_offset;
+ /* Zap the reloc on the _tls_get_addr call too. */
+ BFD_ASSERT (offset == rel[1].r_offset);
+ rel[1].r_info = ELF64_R_INFO (ELF64_R_SYM (rel[1].r_info),
+ R_PPC64_NONE);
+ insn2 = 0x38630000; /* addi 3,3,0 */
+ insn3 = bfd_get_32 (output_bfd,
+ contents + offset + 4);
+ if (insn3 == NOP
+ || insn3 == CROR_151515 || insn3 == CROR_313131)
+ {
+ rel->r_offset += 4;
+ bfd_put_32 (output_bfd, insn2, contents + offset + 4);
+ insn2 = NOP;
+ }
+ bfd_put_32 (output_bfd, insn2, contents + offset);
+ rel--;
+ continue;
+ }
+ break;
+
case R_PPC64_DTPMOD64:
if (rel + 1 < relend
&& rel[1].r_info == ELF64_R_INFO (r_symndx, R_PPC64_DTPREL64)
case R_PPC64_NONE:
case R_PPC64_TLS:
+ case R_PPC64_TLSGD:
+ case R_PPC64_TLSLD:
case R_PPC64_GNU_VTINHERIT:
case R_PPC64_GNU_VTENTRY:
continue;
*offp = off | 1;
if ((info->shared || indx != 0)
- && (h == NULL
+ && (offp == &ppc64_tlsld_got (input_bfd)->offset
+ || h == NULL
|| ELF_ST_VISIBILITY (h->elf.other) == STV_DEFAULT
|| h->elf.root.type != bfd_link_hash_undefweak))
{
&& (h == NULL
|| ELF_ST_VISIBILITY (h->elf.other) == STV_DEFAULT
|| h->elf.root.type != bfd_link_hash_undefweak)
- && (MUST_BE_DYN_RELOC (r_type)
+ && (must_be_dyn_reloc (info, r_type)
|| !SYMBOL_CALLS_LOCAL (info, &h->elf)))
|| (ELIMINATE_COPY_RELOCS
&& !info->shared
&& h != NULL
&& h->elf.dynindx != -1
&& !h->elf.non_got_ref
- && h->elf.def_dynamic
&& !h->elf.def_regular))
{
Elf_Internal_Rela outrel;
{
long indx = 0;
- if (bfd_is_abs_section (sec))
+ if (r_symndx == 0 || bfd_is_abs_section (sec))
;
else if (sec == NULL || sec->owner == NULL)
{
NULL))
return FALSE;
+ if (htab->glink != NULL
+ && htab->glink->reloc_count != 0
+ && !_bfd_elf_link_output_relocs (output_bfd,
+ htab->glink,
+ &elf_section_data (htab->glink)->rel_hdr,
+ elf_section_data (htab->glink)->relocs,
+ NULL))
+ return FALSE;
+
/* We need to handle writing out multiple GOT sections ourselves,
since we didn't add them to DYNOBJ. We know dynobj is the first
bfd. */
{
asection *s;
- if (!is_ppc64_elf_target (dynobj->xvec))
+ if (!is_ppc64_elf (dynobj))
continue;
s = ppc64_elf_tdata (dynobj)->got;