/* PowerPC-specific support for 32-bit ELF
Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
- 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+ 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+ Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
ppc_elf_finish_dynamic_sections is one of the last functions
called. */
-/* The PPC linker needs to keep track of the number of relocs that it
- decides to copy as dynamic relocs in check_relocs for each symbol.
- This is so that it can later discard them if they are found to be
- unnecessary. We store the information in a field extending the
- regular ELF linker hash table. */
-
-struct ppc_elf_dyn_relocs
-{
- struct ppc_elf_dyn_relocs *next;
-
- /* The input section of the reloc. */
- asection *sec;
-
- /* Total number of relocs copied for the input section. */
- bfd_size_type count;
-
- /* Number of pc-relative relocs copied for the input section. */
- bfd_size_type pc_count;
-};
-
/* Track PLT entries needed for a given symbol. We might need more
than one glink entry per symbol when generating a pic binary. */
struct plt_entry
elf_linker_section_pointers_t *linker_section_pointer;
/* Track dynamic relocs copied for this symbol. */
- struct ppc_elf_dyn_relocs *dyn_relocs;
+ struct elf_dyn_relocs *dyn_relocs;
/* Contexts in which symbol is used in the GOT (or TOC).
TLS_GD .. TLS_TLS bits are or'd into the mask as the
{
if (edir->dyn_relocs != NULL)
{
- struct ppc_elf_dyn_relocs **pp;
- struct ppc_elf_dyn_relocs *p;
+ struct elf_dyn_relocs **pp;
+ struct elf_dyn_relocs *p;
/* Add reloc counts against the indirect sym to the direct sym
list. Merge any entries against the same section. */
for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
{
- struct ppc_elf_dyn_relocs *q;
+ struct elf_dyn_relocs *q;
for (q = edir->dyn_relocs; q != NULL; q = q->next)
if (q->sec == p->sec)
{
/* It does not make sense to have a procedure linkage
table entry for a local symbol. */
- (*_bfd_error_handler) (_("%B(%A+0x%lx): %s reloc against "
- "local symbol"),
- abfd,
- sec,
- (long) rel->r_offset,
- ppc_elf_howto_table[r_type]->name);
+ info->callbacks->einfo (_("%H: %s reloc against local symbol\n"),
+ abfd, sec, rel->r_offset,
+ ppc_elf_howto_table[r_type]->name);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
&& (h->root.type == bfd_link_hash_defweak
|| !h->def_regular)))
{
- struct ppc_elf_dyn_relocs *p;
- struct ppc_elf_dyn_relocs **rel_head;
+ struct elf_dyn_relocs *p;
+ struct elf_dyn_relocs **rel_head;
#ifdef DEBUG
fprintf (stderr,
s = sec;
vpp = &elf_section_data (s)->local_dynrel;
- rel_head = (struct ppc_elf_dyn_relocs **) vpp;
+ rel_head = (struct elf_dyn_relocs **) vpp;
}
p = *rel_head;
if (!is_ppc_elf (ibfd) || !is_ppc_elf (obfd))
return TRUE;
- /* Check if we have the same endianess. */
+ /* Check if we have the same endianness. */
if (! _bfd_generic_verify_endian_match (ibfd, obfd))
return FALSE;
r_symndx = ELF32_R_SYM (rel->r_info);
if (r_symndx >= symtab_hdr->sh_info)
{
- struct ppc_elf_dyn_relocs **pp, *p;
+ struct elf_dyn_relocs **pp, *p;
struct ppc_elf_link_hash_entry *eh;
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
&& !expecting_tls_get_addr
&& is_branch_reloc (r_type))
{
- info->callbacks->minfo ("%C __tls_get_addr lost arg, "
+ info->callbacks->minfo ("%H __tls_get_addr lost arg, "
"TLS optimization disabled\n",
ibfd, sec, rel->r_offset);
if (elf_section_data (sec)->relocs != relstart)
could just mark this symbol to exclude it
from tls optimization but it's safer to skip
the entire optimization. */
- info->callbacks->minfo (_("%C arg lost __tls_get_addr, "
+ info->callbacks->minfo (_("%H arg lost __tls_get_addr, "
"TLS optimization disabled\n"),
ibfd, sec, rel->r_offset);
if (elf_section_data (sec)->relocs != relstart)
static bfd_boolean
readonly_dynrelocs (struct elf_link_hash_entry *h)
{
- struct ppc_elf_dyn_relocs *p;
+ struct elf_dyn_relocs *p;
for (p = ppc_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
{
if (h->size == 0)
{
- (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
- h->root.root.string);
+ info->callbacks->einfo (_("dynamic variable `%s' is zero size\n"),
+ h->root.root.string);
return TRUE;
}
struct bfd_link_info *info = inf;
struct ppc_elf_link_hash_entry *eh;
struct ppc_elf_link_hash_table *htab;
- struct ppc_elf_dyn_relocs *p;
+ struct elf_dyn_relocs *p;
if (h->root.type == bfd_link_hash_indirect)
return TRUE;
- if (h->root.type == bfd_link_hash_warning)
- /* When warning symbols are created, they **replace** the "real"
- entry in the hash table, thus we never get to see the real
- symbol in a hash traversal. So look at it now. */
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
htab = ppc_elf_hash_table (info);
if (htab->elf.dynamic_sections_created
|| h->type == STT_GNU_IFUNC)
then they should avoid writing weird assembly. */
if (SYMBOL_CALLS_LOCAL (info, h))
{
- struct ppc_elf_dyn_relocs **pp;
+ struct elf_dyn_relocs **pp;
for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
{
if (htab->is_vxworks)
{
- struct ppc_elf_dyn_relocs **pp;
+ struct elf_dyn_relocs **pp;
for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
{
if (h->root.type == bfd_link_hash_indirect)
return TRUE;
- if (h->root.type == bfd_link_hash_warning)
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
if (readonly_dynrelocs (h))
{
((struct bfd_link_info *) info)->flags |= DF_TEXTREL;
for (s = ibfd->sections; s != NULL; s = s->next)
{
- struct ppc_elf_dyn_relocs *p;
+ struct elf_dyn_relocs *p;
- for (p = ((struct ppc_elf_dyn_relocs *)
+ for (p = ((struct elf_dyn_relocs *)
elf_section_data (s)->local_dynrel);
p != NULL;
p = p->next)
switch (r_type)
{
default:
- (*_bfd_error_handler)
- (_("%B: unknown relocation type %d for symbol %s"),
+ info->callbacks->einfo
+ (_("%B: unknown relocation type %d for symbol %s\n"),
input_bfd, (int) r_type, sym_name);
bfd_set_error (bfd_error_bad_value);
generated by a hash table traversal, the value in the
got at entry m+n bears little relation to the entry m. */
if (addend != 0)
- (*_bfd_error_handler)
- (_("%B(%A+0x%lx): non-zero addend on %s reloc against `%s'"),
- input_bfd,
- input_section,
- (long) rel->r_offset,
+ info->callbacks->einfo
+ (_("%H: non-zero addend on %s reloc against `%s'\n"),
+ input_bfd, input_section, rel->r_offset,
howto->name,
sym_name);
}
non-executable to apply text relocations.
So we'll segfault when trying to run the
indirection function to resolve the reloc. */
- (*_bfd_error_handler)
- (_("%B(%A+0x%lx): relocation %s for indirect "
- "function %s unsupported"),
- input_bfd,
- input_section,
- (long) rel->r_offset,
+ info->callbacks->einfo
+ (_("%H: relocation %s for indirect "
+ "function %s unsupported\n"),
+ input_bfd, input_section, rel->r_offset,
howto->name,
sym_name);
ret = FALSE;
|| (CONST_STRNEQ (name, ".sbss")
&& (name[5] == 0 || name[5] == '.'))))
{
- (*_bfd_error_handler)
+ info->callbacks->einfo
(_("%B: the target (%s) of a %s relocation is "
- "in the wrong output section (%s)"),
+ "in the wrong output section (%s)\n"),
input_bfd,
sym_name,
howto->name,
if (! (CONST_STRNEQ (name, ".sdata2")
|| CONST_STRNEQ (name, ".sbss2")))
{
- (*_bfd_error_handler)
+ info->callbacks->einfo
(_("%B: the target (%s) of a %s relocation is "
- "in the wrong output section (%s)"),
+ "in the wrong output section (%s)\n"),
input_bfd,
sym_name,
howto->name,
}
else
{
- (*_bfd_error_handler)
+ info->callbacks->einfo
(_("%B: the target (%s) of a %s relocation is "
- "in the wrong output section (%s)"),
+ "in the wrong output section (%s)\n"),
input_bfd,
sym_name,
howto->name,
case R_PPC_EMB_RELST_HI:
case R_PPC_EMB_RELST_HA:
case R_PPC_EMB_BIT_FLD:
- (*_bfd_error_handler)
- (_("%B: relocation %s is not yet supported for symbol %s."),
+ info->callbacks->einfo
+ (_("%B: relocation %s is not yet supported for symbol %s\n"),
input_bfd,
howto->name,
sym_name);
&& !((input_section->flags & SEC_DEBUGGING) != 0
&& h->def_dynamic))
{
- (*_bfd_error_handler)
- (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
- input_bfd,
- input_section,
- (long) rel->r_offset,
+ info->callbacks->einfo
+ (_("%H: unresolvable %s relocation against symbol `%s'\n"),
+ input_bfd, input_section, rel->r_offset,
howto->name,
sym_name);
ret = FALSE;
}
else
{
- (*_bfd_error_handler)
- (_("%B(%A+0x%lx): %s reloc against `%s': error %d"),
- input_bfd, input_section,
- (long) rel->r_offset, howto->name, sym_name, (int) r);
+ info->callbacks->einfo
+ (_("%H: %s reloc against `%s': error %d\n"),
+ input_bfd, input_section, rel->r_offset,
+ howto->name, sym_name, (int) r);
ret = FALSE;
}
}
}
else
{
- (*_bfd_error_handler) (_("%s not defined in linker created %s"),
- htab->elf.hgot->root.root.string,
- (htab->sgotplt != NULL
- ? htab->sgotplt->name : htab->got->name));
+ info->callbacks->einfo (_("%s not defined in linker created %s\n"),
+ htab->elf.hgot->root.root.string,
+ (htab->sgotplt != NULL
+ ? htab->sgotplt->name : htab->got->name));
bfd_set_error (bfd_error_bad_value);
ret = FALSE;
}