X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=bfd%2Felf64-alpha.c;h=02dd2abaf6b52e4858c2a019c1cce3feb3135fbb;hb=9f7c3e5e99a620b68f6b2d0f3b17329e40b8d781;hp=528476bdddf680256fa5edf566ab07fd91fc85ba;hpb=fc28f9aa231c8f3386e1c9bdb448d9cdd9cae1a9;p=binutils-gdb.git diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index 528476bdddf..02dd2abaf6b 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -1,6 +1,7 @@ /* 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 + Free Software Foundation, Inc. Contributed by Richard Henderson . This file is part of BFD, the Binary File Descriptor library. @@ -210,7 +211,7 @@ struct alpha_elf_link_hash_table #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. */ @@ -224,7 +225,7 @@ struct alpha_elf_link_hash_table #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. */ @@ -356,7 +357,7 @@ elf64_alpha_object_p (bfd *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) @@ -369,7 +370,7 @@ elf64_alpha_reloc_nil (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc, 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) @@ -421,7 +422,7 @@ elf64_alpha_do_reloc_gpdisp (bfd *abfd, bfd_vma gpdisp, bfd_byte *p_ldah, 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) { @@ -1376,17 +1377,17 @@ elf64_alpha_read_ecoff_info (bfd *abfd, asection *section, } 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; @@ -1451,7 +1452,7 @@ elf64_alpha_find_nearest_line (bfd *abfd, asection *section, asymbol **symbols, 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; @@ -1506,7 +1507,7 @@ elf64_alpha_find_nearest_line (bfd *abfd, asection *section, asymbol **symbols, 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; @@ -1548,7 +1549,7 @@ struct extsym_info }; 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; @@ -2102,7 +2103,7 @@ elf64_alpha_adjust_dynamic_symbol (struct bfd_link_info *info, { 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; @@ -2391,7 +2392,7 @@ elf64_alpha_merge_gots (bfd *a, bfd *b) 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; @@ -2543,7 +2544,8 @@ elf64_alpha_size_got_sections (struct bfd_link_info *info) } 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; @@ -2588,7 +2590,7 @@ elf64_alpha_size_plt_section (struct bfd_link_info *info) 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; @@ -2598,7 +2600,7 @@ elf64_alpha_size_plt_section (struct bfd_link_info *info) 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) { @@ -2614,7 +2616,7 @@ elf64_alpha_size_plt_section (struct bfd_link_info *info) 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; } } @@ -2773,7 +2775,7 @@ elf64_alpha_size_rela_got_1 (struct alpha_elf_link_hash_entry *h, 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; } @@ -2823,7 +2825,7 @@ elf64_alpha_size_rela_got_section (struct bfd_link_info *info) } 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); @@ -2859,7 +2861,7 @@ elf64_alpha_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* 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; @@ -3169,7 +3171,7 @@ elf64_alpha_relax_opt_call (struct alpha_relax_info *info, bfd_vma symval) 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) @@ -3754,7 +3756,7 @@ elf64_alpha_relax_section (bfd *abfd, asection *sec, /* 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; @@ -4107,10 +4109,10 @@ elf64_alpha_relocate_section_r (bfd *output_bfd ATTRIBUTE_UNUSED, 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) @@ -4139,7 +4141,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, 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, @@ -4154,7 +4156,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, 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; @@ -4165,7 +4167,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, (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; @@ -4213,6 +4215,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, 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; @@ -4264,7 +4267,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, 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) { @@ -4294,7 +4297,6 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, else { bfd_boolean warned; - bfd_boolean unresolved_reloc; struct elf_link_hash_entry *hh; struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd); @@ -4316,9 +4318,9 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, 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; @@ -4527,7 +4529,12 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, 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) { @@ -4573,7 +4580,11 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, /* ??? .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; @@ -4718,7 +4729,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, if (r_symndx < symtab_hdr->sh_info && sec != NULL && howto->pc_relative - && elf_discarded_section (sec)) + && discarded_section (sec)) break; if (h != NULL) @@ -4772,9 +4783,9 @@ elf64_alpha_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, 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) @@ -4844,7 +4855,7 @@ elf64_alpha_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, 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; @@ -4879,19 +4890,19 @@ elf64_alpha_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, 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; @@ -4909,7 +4920,7 @@ elf64_alpha_finish_dynamic_sections (bfd *output_bfd, 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) { @@ -4917,8 +4928,8 @@ elf64_alpha_finish_dynamic_sections (bfd *output_bfd, 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; @@ -4926,7 +4937,7 @@ elf64_alpha_finish_dynamic_sections (bfd *output_bfd, 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; @@ -5093,7 +5104,7 @@ elf64_alpha_final_link (bfd *abfd, struct bfd_link_info *info) 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) @@ -5197,7 +5208,7 @@ elf64_alpha_final_link (bfd *abfd, struct bfd_link_info *info) 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) @@ -5244,7 +5255,7 @@ elf64_alpha_final_link (bfd *abfd, struct bfd_link_info *info) einfo.failed = FALSE; elf_link_hash_traverse (elf_hash_table (info), elf64_alpha_output_extsym, - (PTR) &einfo); + &einfo); if (einfo.failed) return FALSE;