/* Alpha specific support for 64-bit ELF
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
+ Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@tamu.edu>.
This file is part of BFD, the Binary File Descriptor library.
#define alpha_elf_link_hash_traverse(table, func, info) \
(elf_link_hash_traverse \
(&(table)->root, \
- (bfd_boolean (*) (struct elf_link_hash_entry *, PTR)) (func), \
+ (bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func), \
(info)))
/* Get the Alpha ELF linker hash table from a link_info structure. */
#define alpha_elf_sym_hashes(abfd) \
((struct alpha_elf_link_hash_entry **)elf_sym_hashes(abfd))
-/* Should we do dynamic things to this symbol? This differs from the
+/* Should we do dynamic things to this symbol? This differs from the
generic version in that we never need to consider function pointer
equality wrt PLT entries -- we don't create a PLT entry if a symbol's
address is ever taken. */
return &ret->root.root;
}
\f
+/* Alpha ELF follows MIPS ELF in using a special find_nearest_line
+ routine in order to handle the ECOFF debugging information. */
+
+struct alpha_elf_find_line
+{
+ struct ecoff_debug_info d;
+ struct ecoff_find_line i;
+};
+
/* We have some private fields hanging off of the elf_tdata structure. */
struct alpha_elf_obj_tdata
/* For every got, this is the sum of the number of words required
to hold all of the member object's local got. */
int local_got_size;
+
+ /* Used by elf64_alpha_find_nearest_line entry point. */
+ struct alpha_elf_find_line *find_line_info;
+
};
#define alpha_elf_tdata(abfd) \
static bfd_reloc_status_type
elf64_alpha_reloc_nil (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc,
asymbol *sym ATTRIBUTE_UNUSED,
- PTR data ATTRIBUTE_UNUSED, asection *sec,
+ void * data ATTRIBUTE_UNUSED, asection *sec,
bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
{
if (output_bfd)
static bfd_reloc_status_type
elf64_alpha_reloc_bad (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc,
asymbol *sym ATTRIBUTE_UNUSED,
- PTR data ATTRIBUTE_UNUSED, asection *sec,
+ void * data ATTRIBUTE_UNUSED, asection *sec,
bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
{
if (output_bfd)
static bfd_reloc_status_type
elf64_alpha_reloc_gpdisp (bfd *abfd, arelent *reloc_entry,
- asymbol *sym ATTRIBUTE_UNUSED, PTR data,
+ asymbol *sym ATTRIBUTE_UNUSED, void * data,
asection *input_section, bfd *output_bfd,
char **err_msg)
{
}
READ (line, cbLineOffset, cbLine, sizeof (unsigned char), unsigned char *);
- READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, PTR);
- READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, PTR);
- READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, PTR);
- READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, PTR);
+ READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, void *);
+ READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, void *);
+ READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, void *);
+ READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, void *);
READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext),
union aux_ext *);
READ (ss, cbSsOffset, issMax, sizeof (char), char *);
READ (ssext, cbSsExtOffset, issExtMax, sizeof (char), char *);
- READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, PTR);
- READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, PTR);
- READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, PTR);
+ READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, void *);
+ READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, void *);
+ READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, void *);
#undef READ
debug->fdr = NULL;
return name[0] == '$';
}
-/* Alpha ELF follows MIPS ELF in using a special find_nearest_line
- routine in order to handle the ECOFF debugging information. We
- still call this mips_elf_find_line because of the slot
- find_line_info in elf_obj_tdata is declared that way. */
-
-struct mips_elf_find_line
-{
- struct ecoff_debug_info d;
- struct ecoff_find_line i;
-};
-
static bfd_boolean
elf64_alpha_find_nearest_line (bfd *abfd, asection *section, asymbol **symbols,
bfd_vma offset, const char **filename_ptr,
{
asection *msec;
- if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+ if (_bfd_dwarf2_find_nearest_line (abfd, dwarf_debug_sections,
+ section, symbols, offset,
filename_ptr, functionname_ptr,
- line_ptr, 0,
+ line_ptr, NULL, 0,
&elf_tdata (abfd)->dwarf2_find_line_info))
return TRUE;
if (msec != NULL)
{
flagword origflags;
- struct mips_elf_find_line *fi;
+ struct alpha_elf_find_line *fi;
const struct ecoff_debug_swap * const swap =
get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
if (elf_section_data (msec)->this_hdr.sh_type != SHT_NOBITS)
msec->flags |= SEC_HAS_CONTENTS;
- fi = elf_tdata (abfd)->find_line_info;
+ fi = alpha_elf_tdata (abfd)->find_line_info;
if (fi == NULL)
{
bfd_size_type external_fdr_size;
char *fraw_src;
char *fraw_end;
struct fdr *fdr_ptr;
- bfd_size_type amt = sizeof (struct mips_elf_find_line);
+ bfd_size_type amt = sizeof (struct alpha_elf_find_line);
- fi = (struct mips_elf_find_line *) bfd_zalloc (abfd, amt);
+ fi = (struct alpha_elf_find_line *) bfd_zalloc (abfd, amt);
if (fi == NULL)
{
msec->flags = origflags;
fraw_end = (fraw_src
+ fi->d.symbolic_header.ifdMax * external_fdr_size);
for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++)
- (*swap->swap_fdr_in) (abfd, (PTR) fraw_src, fdr_ptr);
+ (*swap->swap_fdr_in) (abfd, fraw_src, fdr_ptr);
- elf_tdata (abfd)->find_line_info = fi;
+ alpha_elf_tdata (abfd)->find_line_info = fi;
/* Note that we don't bother to ever free this information.
find_nearest_line is either called all the time, as in
};
static bfd_boolean
-elf64_alpha_output_extsym (struct alpha_elf_link_hash_entry *h, PTR data)
+elf64_alpha_output_extsym (struct alpha_elf_link_hash_entry *h, void * data)
{
struct extsym_info *einfo = (struct extsym_info *) data;
bfd_boolean strip;
|| h->root.root.type == bfd_link_hash_warning)
h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link;
+ /* PR15323, ref flags aren't set for references in the same
+ object. */
+ h->root.root.non_ir_ref = 1;
h->root.ref_regular = 1;
}
{
h->needs_plt = TRUE;
- s = bfd_get_section_by_name(dynobj, ".plt");
+ s = bfd_get_linker_section (dynobj, ".plt");
if (!s && !elf64_alpha_create_dynamic_sections (dynobj, info))
return FALSE;
static bfd_boolean
elf64_alpha_calc_got_offsets_for_symbol (struct alpha_elf_link_hash_entry *h,
- PTR arg ATTRIBUTE_UNUSED)
+ void * arg ATTRIBUTE_UNUSED)
{
struct alpha_elf_got_entry *gotent;
}
static bfd_boolean
-elf64_alpha_size_plt_section_1 (struct alpha_elf_link_hash_entry *h, PTR data)
+elf64_alpha_size_plt_section_1 (struct alpha_elf_link_hash_entry *h,
+ void * data)
{
asection *splt = (asection *) data;
struct alpha_elf_got_entry *gotent;
return;
dynobj = elf_hash_table(info)->dynobj;
- splt = bfd_get_section_by_name (dynobj, ".plt");
+ splt = bfd_get_linker_section (dynobj, ".plt");
if (splt == NULL)
return;
elf64_alpha_size_plt_section_1, splt);
/* Every plt entry requires a JMP_SLOT relocation. */
- spltrel = bfd_get_section_by_name (dynobj, ".rela.plt");
+ spltrel = bfd_get_linker_section (dynobj, ".rela.plt");
entries = 0;
if (splt->size)
{
entire contents of the .got.plt section. */
if (elf64_alpha_use_secureplt)
{
- sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
+ sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
sgotplt->size = entries ? 16 : 0;
}
}
if (entries > 0)
{
bfd *dynobj = elf_hash_table(info)->dynobj;
- asection *srel = bfd_get_section_by_name (dynobj, ".rela.got");
+ asection *srel = bfd_get_linker_section (dynobj, ".rela.got");
BFD_ASSERT (srel != NULL);
srel->size += sizeof (Elf64_External_Rela) * entries;
}
}
dynobj = elf_hash_table(info)->dynobj;
- srel = bfd_get_section_by_name (dynobj, ".rela.got");
+ srel = bfd_get_linker_section (dynobj, ".rela.got");
if (!srel)
{
BFD_ASSERT (entries == 0);
/* 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");
BFD_ASSERT (s != NULL);
s->size = sizeof ELF_DYNAMIC_INTERPRETER;
s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
else
{
tsec_relocs = (_bfd_elf_link_read_relocs
- (info->abfd, info->tsec, (PTR) NULL,
+ (info->abfd, info->tsec, NULL,
(Elf_Internal_Rela *) NULL,
info->link_info->keep_memory));
if (tsec_relocs == NULL)
pos[3] = info->contents + gpdisp->r_offset;
pos[4] = pos[3] + gpdisp->r_addend;
+ /* Beware of the compiler hoisting part of the sequence out a loop
+ and adjusting the destination register for the TLSGD insn. If this
+ happens, there will be a move into $16 before the JSR insn, so only
+ transformations of the first insn pair should use this register. */
+ tlsgd_reg = bfd_get_32 (info->abfd, pos[0]);
+ tlsgd_reg = (tlsgd_reg >> 21) & 31;
+
/* Generally, the positions are not allowed to be out of order, lest the
modified insn sequence have different register lifetimes. We can make
an exception when pos 1 is adjacent to pos 0. */
use_gottprel = FALSE;
new_symndx = is_gd ? ELF64_R_SYM (irel->r_info) : STN_UNDEF;
- /* Beware of the compiler hoisting part of the sequence out a loop
- and adjusting the destination register for the TLSGD insn. If this
- happens, there will be a move into $16 before the JSR insn, so only
- transformations of the first insn pair should use this register. */
- tlsgd_reg = bfd_get_32 (info->abfd, pos[0]);
- tlsgd_reg = (tlsgd_reg >> 21) & 31;
-
- switch (!dynamic && !info->link_info->shared)
+ /* Some compilers warn about a Boolean-looking expression being
+ used in a switch. The explicit cast silences them. */
+ switch ((int) (!dynamic && !info->link_info->shared))
{
case 1:
{
/* Load the relocations for this section. */
internal_relocs = (_bfd_elf_link_read_relocs
- (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+ (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
link_info->keep_memory));
if (internal_relocs == NULL)
return FALSE;
sec = h->root.u.def.section;
}
- if (sec != NULL && elf_discarded_section (sec))
+ if (sec != NULL && discarded_section (sec))
RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
- rel, relend,
- elf64_alpha_howto_table + r_type,
+ rel, 1, relend,
+ elf64_alpha_howto_table + r_type, 0,
contents);
if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
bfd_boolean ret_val;
BFD_ASSERT (is_alpha_elf (input_bfd));
-
+
/* Handle relocatable links with a smaller loop. */
if (info->relocatable)
return elf64_alpha_relocate_section_r (output_bfd, info, input_bfd,
dynobj = elf_hash_table (info)->dynobj;
if (dynobj)
- srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ srelgot = bfd_get_linker_section (dynobj, ".rela.got");
else
srelgot = NULL;
(input_bfd, elf_elfheader(input_bfd)->e_shstrndx,
_bfd_elf_single_rel_hdr (input_section)->sh_name));
BFD_ASSERT(section_name != NULL);
- srel = bfd_get_section_by_name (dynobj, section_name);
+ srel = bfd_get_linker_section (dynobj, section_name);
}
else
srel = NULL;
bfd_vma value;
bfd_vma addend;
bfd_boolean dynamic_symbol_p;
+ bfd_boolean unresolved_reloc = FALSE;
bfd_boolean undef_weak_ref = FALSE;
unsigned long r_type;
unless it has been done already. */
if ((sec->flags & SEC_MERGE)
&& ELF_ST_TYPE (sym->st_info) == STT_SECTION
- && sec->sec_info_type == ELF_INFO_TYPE_MERGE
+ && sec->sec_info_type == SEC_INFO_TYPE_MERGE
&& gotent
&& !gotent->reloc_xlated)
{
}
else
{
- bfd_boolean warned;
- bfd_boolean unresolved_reloc;
+ bfd_boolean warned, ignored;
struct elf_link_hash_entry *hh;
struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
r_symndx, symtab_hdr, sym_hashes,
hh, sec, value,
- unresolved_reloc, warned);
+ unresolved_reloc, warned, ignored);
if (warned)
continue;
gotent = h->got_entries;
}
- if (sec != NULL && elf_discarded_section (sec))
+ if (sec != NULL && discarded_section (sec))
RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
- rel, relend, howto, contents);
+ rel, 1, relend, howto, 0, contents);
addend = rel->r_addend;
value += addend;
else if (info->shared
&& r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC)
- && !undef_weak_ref)
+ && !undef_weak_ref
+ && !(unresolved_reloc
+ && (_bfd_elf_section_offset (output_bfd, info,
+ input_section,
+ rel->r_offset)
+ == (bfd_vma) -1)))
{
if (r_type == R_ALPHA_REFLONG)
{
/* ??? .eh_frame references to discarded sections will be smashed
to relocations against SHN_UNDEF. The .eh_frame format allows
NULL to be encoded as 0 in any format, so this works here. */
- if (r_symndx == STN_UNDEF)
+ if (r_symndx == STN_UNDEF
+ || (unresolved_reloc
+ && _bfd_elf_section_offset (output_bfd, info,
+ input_section,
+ rel->r_offset) == (bfd_vma) -1))
howto = (elf64_alpha_howto_table
+ (r_type - R_ALPHA_SREL32 + R_ALPHA_REFLONG));
goto default_reloc;
if (r_symndx < symtab_hdr->sh_info
&& sec != NULL && howto->pc_relative
- && elf_discarded_section (sec))
+ && discarded_section (sec))
break;
if (h != NULL)
BFD_ASSERT (h->dynindx != -1);
- splt = bfd_get_section_by_name (dynobj, ".plt");
+ splt = bfd_get_linker_section (dynobj, ".plt");
BFD_ASSERT (splt != NULL);
- srel = bfd_get_section_by_name (dynobj, ".rela.plt");
+ srel = bfd_get_linker_section (dynobj, ".rela.plt");
BFD_ASSERT (srel != NULL);
for (gotent = ah->got_entries; gotent ; gotent = gotent->next)
asection *srel;
struct alpha_elf_got_entry *gotent;
- srel = bfd_get_section_by_name (dynobj, ".rela.got");
+ srel = bfd_get_linker_section (dynobj, ".rela.got");
BFD_ASSERT (srel != NULL);
for (gotent = ((struct alpha_elf_link_hash_entry *) h)->got_entries;
abort ();
}
- elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel,
+ elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel,
gotent->got_offset, h->dynindx,
r_type, gotent->addend);
if (gotent->reloc_type == R_ALPHA_TLSGD)
- elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel,
+ elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel,
gotent->got_offset + 8, h->dynindx,
R_ALPHA_DTPREL64, gotent->addend);
}
}
/* Mark some specially defined symbols as absolute. */
- if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+ if (h == elf_hash_table (info)->hdynamic
|| h == elf_hash_table (info)->hgot
|| h == elf_hash_table (info)->hplt)
sym->st_shndx = SHN_ABS;
asection *sdyn;
dynobj = elf_hash_table (info)->dynobj;
- sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+ sdyn = bfd_get_linker_section (dynobj, ".dynamic");
if (elf_hash_table (info)->dynamic_sections_created)
{
Elf64_External_Dyn *dyncon, *dynconend;
bfd_vma plt_vma, gotplt_vma;
- splt = bfd_get_section_by_name (dynobj, ".plt");
- srelaplt = bfd_get_section_by_name (output_bfd, ".rela.plt");
+ splt = bfd_get_linker_section (dynobj, ".plt");
+ srelaplt = bfd_get_linker_section (output_bfd, ".rela.plt");
BFD_ASSERT (splt != NULL && sdyn != NULL);
plt_vma = splt->output_section->vma + splt->output_offset;
gotplt_vma = 0;
if (elf64_alpha_use_secureplt)
{
- sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
+ sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
BFD_ASSERT (sgotplt != NULL);
if (sgotplt->size > 0)
gotplt_vma = sgotplt->output_section->vma + sgotplt->output_offset;
debug.external_ext = debug.external_ext_end = NULL;
mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info);
- if (mdebug_handle == (PTR) NULL)
+ if (mdebug_handle == NULL)
return FALSE;
if (1)
const char *name;
struct alpha_elf_link_hash_entry *h;
- (*input_swap->swap_ext_in) (input_bfd, (PTR) eraw_src, &ext);
+ (*input_swap->swap_ext_in) (input_bfd, eraw_src, &ext);
if (ext.asym.sc == scNil
|| ext.asym.sc == scUndefined
|| ext.asym.sc == scSUndefined)
einfo.failed = FALSE;
elf_link_hash_traverse (elf_hash_table (info),
elf64_alpha_output_extsym,
- (PTR) &einfo);
+ &einfo);
if (einfo.failed)
return FALSE;
}
static enum elf_reloc_type_class
-elf64_alpha_reloc_type_class (const Elf_Internal_Rela *rela)
+elf64_alpha_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ const asection *rel_sec ATTRIBUTE_UNUSED,
+ const Elf_Internal_Rela *rela)
{
switch ((int) ELF64_R_TYPE (rela->r_info))
{