X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf32-nds32.c;h=94fb0374396a2a59d6fac1b9c73a3de0e3ef5613;hb=5524b5250e319f41933605420e9526fb74cfb9ae;hp=ed4383db5a341dda1b604648668b5a6fa49c4e5d;hpb=64d2901806c171c0d949f8fb1b29b4e5ba8cf04d;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index ed4383db5a..94fb037439 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -1,5 +1,5 @@ /* NDS32-specific support for 32-bit ELF. - Copyright (C) 2012-2015 Free Software Foundation, Inc. + Copyright (C) 2012-2017 Free Software Foundation, Inc. Contributed by Andes Technology Corporation. This file is part of BFD, the Binary File Descriptor library. @@ -77,7 +77,8 @@ static bfd_boolean nds32_elf_relocate_section static bfd_boolean nds32_elf_object_p (bfd *); static void nds32_elf_final_write_processing (bfd *, bfd_boolean); static bfd_boolean nds32_elf_set_private_flags (bfd *, flagword); -static bfd_boolean nds32_elf_merge_private_bfd_data (bfd *, bfd *); +static bfd_boolean nds32_elf_merge_private_bfd_data + (bfd *, struct bfd_link_info *); static bfd_boolean nds32_elf_print_private_bfd_data (bfd *, void *); static bfd_boolean nds32_elf_gc_sweep_hook (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); @@ -2300,7 +2301,7 @@ nds32_insertion_sort (void *base, size_t nmemb, size_t size, { char *ptr = (char *) base; int i, j; - char *tmp = alloca (size); + char *tmp = xmalloc (size); /* If i is less than j, i is inserted before j. @@ -2324,6 +2325,7 @@ nds32_insertion_sort (void *base, size_t nmemb, size_t size, memmove (ptr + (j + 1) * size, ptr + j * size, (i - j) * size); memcpy (ptr + j * size, tmp, size); } + free (tmp); } /* Sort relocation by r_offset. @@ -2968,6 +2970,7 @@ nds32_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, r_type = ELF32_R_TYPE (dst->r_info); if (r_type > R_NDS32_GNU_VTENTRY) { + /* xgettext:c-format */ _bfd_error_handler (_("%B: invalid NDS32 reloc number: %d"), abfd, r_type); r_type = 0; } @@ -3045,6 +3048,7 @@ nds32_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) _bfd_elfcore_strndup (abfd, note->descdata + 28, 16); elf_tdata (abfd)->core->command = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80); + break; default: return FALSE; @@ -3291,7 +3295,7 @@ nds32_elf_final_sda_base (bfd *output_bfd, struct bfd_link_info *info, } } - if (add_symbol == TRUE) + if (add_symbol) { if (h) { @@ -3302,7 +3306,7 @@ nds32_elf_final_sda_base (bfd *output_bfd, struct bfd_link_info *info, } else { - (*_bfd_error_handler) (_("error: Can't find symbol: _SDA_BASE_.")); + _bfd_error_handler (_("error: Can't find symbol: _SDA_BASE_.")); return bfd_reloc_dangerous; } } @@ -3376,50 +3380,9 @@ nds32_elf_link_hash_table_create (bfd *abfd) return NULL; } - ret->sgot = NULL; - ret->sgotplt = NULL; - ret->srelgot = NULL; - ret->splt = NULL; - ret->srelplt = NULL; - ret->sdynbss = NULL; - ret->srelbss = NULL; - ret->sym_ld_script = NULL; - ret->ex9_export_file = NULL; - ret->ex9_import_file = NULL; - return &ret->root.root; } -/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up - shortcuts to them in our hash table. */ - -static bfd_boolean -create_got_section (bfd *dynobj, struct bfd_link_info *info) -{ - struct elf_nds32_link_hash_table *htab; - - if (!_bfd_elf_create_got_section (dynobj, info)) - return FALSE; - - htab = nds32_elf_hash_table (info); - htab->sgot = bfd_get_section_by_name (dynobj, ".got"); - htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); - if (!htab->sgot || !htab->sgotplt) - abort (); - - /* _bfd_elf_create_got_section will create it for us. */ - htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); - if (htab->srelgot == NULL - || !bfd_set_section_flags (dynobj, htab->srelgot, - (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS - | SEC_IN_MEMORY | SEC_LINKER_CREATED - | SEC_READONLY)) - || !bfd_set_section_alignment (dynobj, htab->srelgot, 2)) - return FALSE; - - return TRUE; -} - /* Create dynamic sections when linking against a dynamic object. */ static bfd_boolean @@ -3449,7 +3412,7 @@ nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) pltflags |= SEC_READONLY; s = bfd_make_section (abfd, ".plt"); - htab->splt = s; + htab->root.splt = s; if (s == NULL || !bfd_set_section_flags (abfd, s, pltflags) || !bfd_set_section_alignment (abfd, s, bed->plt_alignment)) @@ -3472,19 +3435,19 @@ nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) h->def_regular = 1; h->type = STT_OBJECT; - if (info->shared && !bfd_elf_link_record_dynamic_symbol (info, h)) + if (bfd_link_pic (info) && !bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; } s = bfd_make_section (abfd, bed->default_use_rela_p ? ".rela.plt" : ".rel.plt"); - htab->srelplt = s; + htab->root.srelplt = s; if (s == NULL || !bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || !bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; - if (htab->sgot == NULL && !create_got_section (abfd, info)) + if (htab->root.sgot == NULL && !_bfd_elf_create_got_section (abfd, info)) return FALSE; { @@ -3537,7 +3500,7 @@ nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) be needed, we can discard it later. We will never need this section when generating a shared object, since they do not use copy relocs. */ - if (!info->shared) + if (!bfd_link_pic (info)) { s = bfd_make_section (abfd, (bed->default_use_rela_p ? ".rela.bss" : ".rel.bss")); @@ -3632,7 +3595,7 @@ nds32_elf_adjust_dynamic_symbol (struct bfd_link_info *info, when we know the address of the .got section. */ if (h->type == STT_FUNC || h->needs_plt) { - if (!info->shared + if (!bfd_link_pic (info) && !h->def_dynamic && !h->ref_dynamic && h->root.type != bfd_link_hash_undefweak @@ -3671,7 +3634,7 @@ nds32_elf_adjust_dynamic_symbol (struct bfd_link_info *info, only references to the symbol are via the global offset table. For such cases we need not do anything here; the relocations will be handled correctly by relocate_section. */ - if (info->shared) + if (bfd_link_pic (info)) return TRUE; /* If there are no references to this symbol that do not use the @@ -3790,9 +3753,9 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return FALSE; } - if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h)) + if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h)) { - asection *s = htab->splt; + asection *s = htab->root.splt; /* If this is the first .plt entry, make room for the special first entry. */ @@ -3806,7 +3769,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) location in the .plt. This is required to make function pointers compare as equal between the normal executable and the shared library. */ - if (!info->shared && !h->def_regular) + if (!bfd_link_pic (info) && !h->def_regular) { h->root.u.def.section = s; h->root.u.def.value = h->plt.offset; @@ -3817,10 +3780,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ - htab->sgotplt->size += 4; + htab->root.sgotplt->size += 4; /* We also need to make an entry in the .rel.plt section. */ - htab->srelplt->size += sizeof (Elf32_External_Rela); + htab->root.srelplt->size += sizeof (Elf32_External_Rela); } else { @@ -3848,7 +3811,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return FALSE; } - s = htab->sgot; + s = htab->root.sgot; h->got.offset = s->size; if (tls_type == GOT_UNKNOWN) @@ -3859,8 +3822,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) s->size += 4; dyn = htab->root.dynamic_sections_created; - if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)) - htab->srelgot->size += sizeof (Elf32_External_Rela); + if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h)) + htab->root.srelgot->size += sizeof (Elf32_External_Rela); } else h->got.offset = (bfd_vma) - 1; @@ -3874,7 +3837,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) space for pc-relative relocs that have become local due to symbol visibility changes. */ - if (info->shared) + if (bfd_link_pic (info)) { if (h->def_regular && (h->forced_local || info->symbolic)) { @@ -3980,7 +3943,7 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, if (htab->root.dynamic_sections_created) { /* Set the contents of the .interp section to the interpreter. */ - if (!info->shared) + if (!bfd_link_pic (info) && !info->nointerp) { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); @@ -4035,15 +3998,15 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; locsymcount = symtab_hdr->sh_info; end_local_got = local_got + locsymcount; - s = htab->sgot; - srel = htab->srelgot; + s = htab->root.sgot; + srel = htab->root.srelgot; for (; local_got < end_local_got; ++local_got) { if (*local_got > 0) { *local_got = s->size; s->size += 4; - if (info->shared) + if (bfd_link_pic (info)) srel->size += sizeof (Elf32_External_Rela); } else @@ -4063,22 +4026,22 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, if ((s->flags & SEC_LINKER_CREATED) == 0) continue; - if (s == htab->splt) + if (s == htab->root.splt) { /* Strip this section if we don't need it; see the comment below. */ } - else if (s == htab->sgot) + else if (s == htab->root.sgot) { got_size += s->size; } - else if (s == htab->sgotplt) + else if (s == htab->root.sgotplt) { got_size += s->size; } else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) { - if (s->size != 0 && s != htab->srelplt) + if (s->size != 0 && s != htab->root.srelplt) relocs = TRUE; /* We use the reloc_count field as a counter if we need @@ -4127,13 +4090,13 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, #define add_dynamic_entry(TAG, VAL) \ _bfd_elf_add_dynamic_entry (info, TAG, VAL) - if (!info->shared) + if (!bfd_link_pic (info)) { if (!add_dynamic_entry (DT_DEBUG, 0)) return FALSE; } - if (htab->splt->size != 0) + if (htab->root.splt->size != 0) { if (!add_dynamic_entry (DT_PLTGOT, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0) @@ -4495,8 +4458,8 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, dynobj = htab->root.dynobj; local_got_offsets = elf_local_got_offsets (input_bfd); - sgot = htab->sgot; - splt = htab->splt; + sgot = htab->root.sgot; + splt = htab->root.splt; sreloc = NULL; rel = relocs; @@ -4505,7 +4468,7 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, table = nds32_elf_hash_table (info); eliminate_gc_relocs = table->eliminate_gc_relocs; /* By this time, we can adjust the value of _SDA_BASE_. */ - if ((!info->relocatable)) + if ((!bfd_link_relocatable (info))) { is_SDA_BASE_set = 1; r = nds32_elf_final_sda_base (output_bfd, info, &gp, TRUE); @@ -4518,15 +4481,15 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, /* Set the _ITB_BASE_. */ if (!nds32_elf_ex9_itb_base (info)) { - (*_bfd_error_handler) (_("%B: error: Cannot set _ITB_BASE_"), - output_bfd); + _bfd_error_handler (_("%B: error: Cannot set _ITB_BASE_"), + output_bfd); bfd_set_error (bfd_error_bad_value); } } if (table->target_optimize & NDS32_RELAX_JUMP_IFC_ON) if (!nds32_elf_ifc_reloc ()) - (*_bfd_error_handler) (_("error: IFC relocation error.")); + _bfd_error_handler (_("error: IFC relocation error.")); /* Relocation for .ex9.itable. */ if (table->target_optimize & NDS32_RELAX_EX9_ON @@ -4559,8 +4522,9 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, r_type = ELF32_R_TYPE (rel->r_info); if (r_type >= R_NDS32_max) { - (*_bfd_error_handler) (_("%B: error: unknown relocation type %d."), - input_bfd, r_type); + /* xgettext:c-format */ + _bfd_error_handler (_("%B: error: unknown relocation type %d."), + input_bfd, r_type); bfd_set_error (bfd_error_bad_value); ret = FALSE; continue; @@ -4597,7 +4561,7 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, if (((r_type >= R_NDS32_DWARF2_OP1_RELA && r_type <= R_NDS32_DWARF2_LEB_RELA) - || r_type >= R_NDS32_RELAX_ENTRY) && !info->relocatable) + || r_type >= R_NDS32_RELAX_ENTRY) && !bfd_link_relocatable (info)) continue; howto = bfd_elf32_bfd_reloc_type_table_lookup (r_type); @@ -4645,7 +4609,7 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, } - if (info->relocatable) + if (bfd_link_relocatable (info)) { /* This is a relocatable link. We don't have to change anything, unless the reloc is against a section symbol, @@ -4805,8 +4769,10 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, off = h->got.offset; BFD_ASSERT (off != (bfd_vma) - 1); dyn = htab->root.dynamic_sections_created; - if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) - || (info->shared + if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, + bfd_link_pic (info), + h) + || (bfd_link_pic (info) && (info->symbolic || h->dynindx == -1 || h->forced_local) && h->def_regular)) @@ -4853,14 +4819,14 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, { bfd_put_32 (output_bfd, relocation, sgot->contents + off); - if (info->shared) + if (bfd_link_pic (info)) { asection *srelgot; Elf_Internal_Rela outrel; /* We need to generate a R_NDS32_RELATIVE reloc for the dynamic linker. */ - srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); + srelgot = htab->root.srelgot; BFD_ASSERT (srelgot != NULL); outrel.r_offset = (elf_gp (output_bfd) @@ -4899,7 +4865,7 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, case R_NDS32_LO12S1_RELA: case R_NDS32_LO12S0_RELA: case R_NDS32_LO12S0_ORI_RELA: - if (info->shared && r_symndx != 0 + if (bfd_link_pic (info) && r_symndx != 0 && (input_section->flags & SEC_ALLOC) != 0 && (eliminate_gc_relocs == 0 || (sec && (sec->flags & SEC_EXCLUDE) == 0)) @@ -5000,11 +4966,11 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, break; case R_NDS32_25_ABS_RELA: - if (info->shared) + if (bfd_link_pic (info)) { - (*_bfd_error_handler) - (_("%s: warning: cannot deal R_NDS32_25_ABS_RELA in shared " - "mode."), bfd_get_filename (input_bfd)); + _bfd_error_handler + (_("%B: warning: cannot deal R_NDS32_25_ABS_RELA in shared " + "mode."), input_bfd); return FALSE; } break; @@ -5060,11 +5026,12 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, dyn = htab->root.dynamic_sections_created; if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL - (dyn, info->shared, h) || (info->shared - && (info->symbolic - || h->dynindx == -1 - || h->forced_local) - && h->def_regular)) + (dyn, bfd_link_pic (info), h) + || (bfd_link_pic (info) + && (info->symbolic + || h->dynindx == -1 + || h->forced_local) + && h->def_regular)) { /* This is actually a static link, or it is a -Bsymbolic link and the symbol is defined @@ -5106,14 +5073,14 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, { bfd_put_32 (output_bfd, relocation, sgot->contents + off); - if (info->shared) + if (bfd_link_pic (info)) { asection *srelgot; Elf_Internal_Rela outrel; /* We need to generate a R_NDS32_RELATIVE reloc for the dynamic linker. */ - srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); + srelgot = htab->root.srelgot; BFD_ASSERT (srelgot != NULL); outrel.r_offset = (elf_gp (output_bfd) @@ -5135,7 +5102,7 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, if (relocation & align) { /* Incorrect alignment. */ - (*_bfd_error_handler) + _bfd_error_handler (_("%B: warning: unaligned access to GOT entry."), input_bfd); ret = FALSE; r = bfd_reloc_dangerous; @@ -5177,7 +5144,7 @@ handle_sda: r = nds32_elf_final_sda_base (output_bfd, info, &gp, FALSE); if (r != bfd_reloc_ok) { - (*_bfd_error_handler) + _bfd_error_handler (_("%B: warning: relocate SDA_BASE failed."), input_bfd); ret = FALSE; goto check_reloc; @@ -5198,7 +5165,8 @@ handle_sda: if (relocation & align) { /* Incorrect alignment. */ - (*_bfd_error_handler) + _bfd_error_handler + /* xgettext:c-format */ (_("%B(%A): warning: unaligned small data access of type %d."), input_bfd, input_section, r_type); ret = FALSE; @@ -5242,8 +5210,8 @@ handle_sda: BFD_ASSERT (off != (bfd_vma) - 1); dyn = htab->root.dynamic_sections_created; tls_type = ((struct elf_nds32_link_hash_entry *) h)->tls_type; - if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) - && (!info->shared + if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h) + && (!bfd_link_pic (info) || !SYMBOL_REFERENCES_LOCAL (info, h))) indx = h->dynindx; } @@ -5270,8 +5238,8 @@ handle_sda: else { bfd_boolean need_relocs = FALSE; - srelgot = htab->srelgot; - if ((info->shared || indx != 0) + srelgot = htab->root.srelgot; + if ((bfd_link_pic (info) || indx != 0) && (h == NULL || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak)) @@ -5420,16 +5388,14 @@ check_reloc: switch (r) { case bfd_reloc_overflow: - if (!((*info->callbacks->reloc_overflow) - (info, (h ? &h->root : NULL), name, howto->name, - (bfd_vma) 0, input_bfd, input_section, offset))) - return FALSE; + (*info->callbacks->reloc_overflow) + (info, (h ? &h->root : NULL), name, howto->name, + (bfd_vma) 0, input_bfd, input_section, offset); break; case bfd_reloc_undefined: - if (!((*info->callbacks->undefined_symbol) - (info, name, input_bfd, input_section, offset, TRUE))) - return FALSE; + (*info->callbacks->undefined_symbol) + (info, name, input_bfd, input_section, offset, TRUE); break; case bfd_reloc_outofrange: @@ -5448,10 +5414,9 @@ check_reloc: errmsg = _("internal error: unknown error"); /* Fall through. */ -common_error: - if (!((*info->callbacks->warning) - (info, errmsg, name, input_bfd, input_section, offset))) - return FALSE; + common_error: + (*info->callbacks->warning) (info, errmsg, name, input_bfd, + input_section, offset); break; } } @@ -5488,9 +5453,9 @@ nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, BFD_ASSERT (h->dynindx != -1); - splt = htab->splt; - sgot = htab->sgotplt; - srela = htab->srelplt; + splt = htab->root.splt; + sgot = htab->root.sgotplt; + srela = htab->root.srelplt; BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL); /* Get the index in the procedure linkage table which @@ -5505,7 +5470,7 @@ nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, got_offset = (plt_index + 3) * 4; /* Fill in the entry in the procedure linkage table. */ - if (!info->shared) + if (!bfd_link_pic (info)) { unsigned long insn; @@ -5597,8 +5562,8 @@ nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, /* This symbol has an entry in the global offset table. Set it up. */ - sgot = htab->sgot; - srela = htab->srelgot; + sgot = htab->root.sgot; + srela = htab->root.srelgot; BFD_ASSERT (sgot != NULL && srela != NULL); rela.r_offset = (sgot->output_section->vma @@ -5609,7 +5574,7 @@ nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, the symbol was forced to be local because of a version file. The entry in the global offset table will already have been initialized in the relocate_section function. */ - if (info->shared + if (bfd_link_pic (info) && (info->symbolic || h->dynindx == -1 || h->forced_local) && h->def_regular) { @@ -5680,7 +5645,7 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) htab = nds32_elf_hash_table (info); dynobj = htab->root.dynobj; - sgot = htab->sgotplt; + sgot = htab->root.sgotplt; sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); if (htab->root.dynamic_sections_created) @@ -5706,49 +5671,28 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) break; case DT_PLTGOT: - /* name = ".got"; */ - s = htab->sgot->output_section; + s = htab->root.sgotplt; goto get_vma; case DT_JMPREL: - s = htab->srelplt->output_section; + s = htab->root.srelplt; get_vma: - BFD_ASSERT (s != NULL); - dyn.d_un.d_ptr = s->vma; + dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; case DT_PLTRELSZ: - s = htab->srelplt->output_section; - BFD_ASSERT (s != NULL); + s = htab->root.srelplt; dyn.d_un.d_val = s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; - - case DT_RELASZ: - /* My reading of the SVR4 ABI indicates that the - procedure linkage table relocs (DT_JMPREL) should be - included in the overall relocs (DT_RELA). This is - what Solaris does. However, UnixWare can not handle - that case. Therefore, we override the DT_RELASZ entry - here to make it not include the JMPREL relocs. Since - the linker script arranges for .rela.plt to follow all - other relocation sections, we don't have to worry - about changing the DT_RELA entry. */ - if (htab->srelplt != NULL) - { - s = htab->srelplt->output_section; - dyn.d_un.d_val -= s->size; - } - bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); - break; } } /* Fill in the first entry in the procedure linkage table. */ - splt = htab->splt; + splt = htab->root.splt; if (splt && splt->size > 0) { - if (info->shared) + if (bfd_link_pic (info)) { unsigned long insn; long offset; @@ -5969,11 +5913,13 @@ nds32_check_vec_size (bfd *ibfd) nds32_vec_size = (flag_t & 0x3); else if (nds32_vec_size != (flag_t & 0x3)) { - (*_bfd_error_handler) (_("%B: ISR vector size mismatch" - " with previous modules, previous %u-byte, current %u-byte"), - ibfd, - nds32_vec_size == 1 ? 4 : nds32_vec_size == 2 ? 16 : 0xffffffff, - (flag_t & 0x3) == 1 ? 4 : (flag_t & 0x3) == 2 ? 16 : 0xffffffff); + _bfd_error_handler + /* xgettext:c-format */ + (_("%B: ISR vector size mismatch" + " with previous modules, previous %u-byte, current %u-byte"), + ibfd, + nds32_vec_size == 1 ? 4 : nds32_vec_size == 2 ? 16 : 0xffffffff, + (flag_t & 0x3) == 1 ? 4 : (flag_t & 0x3) == 2 ? 16 : 0xffffffff); return FALSE; } else @@ -5988,8 +5934,9 @@ nds32_check_vec_size (bfd *ibfd) object file when linking. */ static bfd_boolean -nds32_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) +nds32_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { + bfd *obfd = info->output_bfd; flagword out_flags; flagword in_flags; flagword out_16regs; @@ -6011,7 +5958,7 @@ nds32_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) if (bfd_little_endian (ibfd) != bfd_little_endian (obfd)) { - (*_bfd_error_handler) + _bfd_error_handler (_("%B: warning: Endian mismatch with previous modules."), ibfd); bfd_set_error (bfd_error_bad_value); @@ -6021,7 +5968,7 @@ nds32_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) in_version = elf_elfheader (ibfd)->e_flags & EF_NDS32_ELF_VERSION; if (in_version == E_NDS32_ELF_VER_1_2) { - (*_bfd_error_handler) + _bfd_error_handler (_("%B: warning: Older version of object file encountered, " "Please recompile with current tool chain."), ibfd); } @@ -6099,7 +6046,7 @@ nds32_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) /* Check flag compatibility. */ if ((in_flags & EF_NDS_ABI) != (out_flags & EF_NDS_ABI)) { - (*_bfd_error_handler) + _bfd_error_handler (_("%B: error: ABI mismatch with previous modules."), ibfd); bfd_set_error (bfd_error_bad_value); @@ -6110,7 +6057,7 @@ nds32_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) { if (((in_flags & EF_NDS_ARCH) != E_N1_ARCH)) { - (*_bfd_error_handler) + _bfd_error_handler (_("%B: error: Instruction set mismatch with previous modules."), ibfd); bfd_set_error (bfd_error_bad_value); @@ -6135,9 +6082,11 @@ nds32_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) else { if (in_version != out_version) - (*_bfd_error_handler) (_("%B: warning: Incompatible elf-versions %s and %s."), - ibfd, nds32_elfver_strtab[out_version], - nds32_elfver_strtab[in_version]); + _bfd_error_handler + /* xgettext:c-format */ + (_("%B: warning: Incompatible elf-versions %s and %s."), + ibfd, nds32_elfver_strtab[out_version], + nds32_elfver_strtab[in_version]); elf_elfheader (obfd)->e_flags = in_flags | out_flags | (in_16regs & out_16regs) | (in_no_mac & out_no_mac) @@ -6299,7 +6248,7 @@ nds32_elf_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info, asection *sec, struct elf_nds32_dyn_relocs **pp; struct elf_nds32_dyn_relocs *p; - if (!info->shared && h->plt.refcount > 0) + if (!bfd_link_pic (info) && h->plt.refcount > 0) h->plt.refcount -= 1; eh = (struct elf_nds32_link_hash_entry *) h; @@ -6352,7 +6301,7 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, bfd *dynobj; asection *sreloc = NULL; - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; symtab_hdr = &elf_tdata (abfd)->symtab_hdr; @@ -6388,7 +6337,7 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, /* Some relocs require a global offset table. We create got section here, since these relocation need got section and it is not created yet. */ - if (htab->sgot == NULL) + if (htab->root.sgot == NULL) { switch (r_type) { @@ -6411,7 +6360,7 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_NDS32_TLS_IE_LO12S2: if (dynobj == NULL) htab->root.dynobj = dynobj = abfd; - if (!create_got_section (dynobj, info)) + if (!_bfd_elf_create_got_section (dynobj, info)) return FALSE; break; @@ -6537,7 +6486,7 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_NDS32_17_PCREL_RELA: case R_NDS32_25_PCREL_RELA: - if (h != NULL && !info->shared) + if (h != NULL && !bfd_link_pic (info)) { h->non_got_ref = 1; h->plt.refcount += 1; @@ -6559,7 +6508,7 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, If on the other hand, we are creating an executable, we may need to keep relocations for symbols satisfied by a dynamic library if we manage to avoid copy relocs for the symbol. */ - if ((info->shared + if ((bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0 && ((r_type != R_NDS32_25_PCREL_RELA && r_type != R_NDS32_15_PCREL_RELA @@ -6570,7 +6519,7 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, && (!info->symbolic || h->root.type == bfd_link_hash_defweak || !h->def_regular)))) - || (!info->shared + || (!bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0 && h != NULL && (h->root.type == bfd_link_hash_defweak @@ -6626,6 +6575,7 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, else { asection *s; + void *vpp; Elf_Internal_Sym *isym; isym = bfd_sym_from_r_symndx (&htab->sym_cache, abfd, r_symndx); @@ -6637,8 +6587,8 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, if (s == NULL) return FALSE; - head = ((struct elf_nds32_dyn_relocs **) - &elf_section_data (s)->local_dynrel); + vpp = &elf_section_data (s)->local_dynrel; + head = (struct elf_nds32_dyn_relocs **) vpp; } p = *head; @@ -6816,7 +6766,7 @@ calculate_plt_memory_address (bfd *abfd, struct bfd_link_info *link_info, h = elf_sym_hashes (abfd)[indx]; BFD_ASSERT (h != NULL); htab = nds32_elf_hash_table (link_info); - splt = htab->splt; + splt = htab->root.splt; while (h->root.type == bfd_link_hash_indirect || h->root.type == bfd_link_hash_warning) @@ -6865,7 +6815,7 @@ nds32_convert_32_to_16_alu1 (bfd *abfd, uint32_t insn, uint16_t *pinsn16, int *pinsn_type) { uint16_t insn16 = 0; - int insn_type; + int insn_type = 0; unsigned long mach = bfd_get_mach (abfd); if (N32_SH5 (insn) != 0) @@ -8092,15 +8042,17 @@ calculate_got_memory_address (bfd *abfd, struct bfd_link_info *link_info, if (symndx >= 0) { BFD_ASSERT (h != NULL); - return htab->sgot->output_section->vma + htab->sgot->output_offset - + h->got.offset; + return (htab->root.sgot->output_section->vma + + htab->root.sgot->output_offset + + h->got.offset); } else { local_got_offsets = elf_local_got_offsets (abfd); BFD_ASSERT (local_got_offsets != NULL); - return htab->sgot->output_section->vma + htab->sgot->output_offset - + local_got_offsets[ELF32_R_SYM (irel->r_info)]; + return (htab->root.sgot->output_section->vma + + htab->root.sgot->output_offset + + local_got_offsets[ELF32_R_SYM (irel->r_info)]); } /* The _GLOBAL_OFFSET_TABLE_ may be undefweak(or should be?). */ @@ -8328,7 +8280,7 @@ static Elf_Internal_Rela * find_relocs_at_address_addr (Elf_Internal_Rela *reloc, Elf_Internal_Rela *relocs, Elf_Internal_Rela *irelend, - unsigned char reloc_type, + enum elf_nds32_reloc_type reloc_type, bfd_vma offset_p) { Elf_Internal_Rela *rel_t = NULL; @@ -8679,7 +8631,7 @@ nds32_elf_relax_delete_blanks (bfd *abfd, asection *sec, unsigned long val = 0; unsigned long mask; long before, between; - long offset; + long offset = 0; switch (ELF32_R_TYPE (irel->r_info)) { @@ -8744,8 +8696,8 @@ nds32_elf_relax_delete_blanks (bfd *abfd, asection *sec, unsigned long before, between; bfd_byte *endp, *p; - val = read_unsigned_leb128 (abfd, contents + irel->r_offset, - &len); + val = _bfd_read_unsigned_leb128 (abfd, contents + irel->r_offset, + &len); before = get_nds32_elf_blank_total (&blank_t, irel->r_addend, 0); between = get_nds32_elf_blank_total (&blank_t, @@ -8774,9 +8726,8 @@ done_adjust_diff: if (blank_t2 && blank_t2->next && (blank_t2->offset > raddr || blank_t2->next->offset <= raddr)) - (*_bfd_error_handler) - (_("%B: %s\n"), abfd, - "Error: search_nds32_elf_blank reports wrong node"); + _bfd_error_handler + (_("%B: Error: search_nds32_elf_blank reports wrong node\n"), abfd); /* Mark reloc in deleted portion as NONE. For some relocs like R_NDS32_LABEL that doesn't modify the @@ -9033,6 +8984,10 @@ relax_range_measurement (bfd *abfd) #define IS_OPTIMIZE(addend) ((addend) & 0x40000000) #define IS_16BIT_ON(addend) ((addend) & 0x20000000) +static const char * unrecognized_reloc_msg = + /* xgettext:c-format */ + N_("%B: warning: %s points to unrecognized reloc at 0x%lx."); + /* Relax LONGCALL1 relocation for nds32_elf_relax_section. */ static bfd_boolean @@ -9083,9 +9038,8 @@ nds32_elf_relax_longcall1 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (hi_irelfn == irelend || lo_irelfn == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGCALL1 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL1", + (long) irel->r_offset); return FALSE; } @@ -9165,9 +9119,8 @@ nds32_elf_relax_longcall2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (i1_irelfn == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGCALL2 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL2", + (long) irel->r_offset); return FALSE; } @@ -9272,9 +9225,8 @@ nds32_elf_relax_longcall3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (hi_irelfn == irelend || lo_irelfn == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGCALL3 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL3", + (long) irel->r_offset); return FALSE; } @@ -9407,9 +9359,8 @@ nds32_elf_relax_longjump1 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, R_NDS32_LO12S0_ORI_RELA, laddr + 4); if (hi_irelfn == irelend || lo_irelfn == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGJUMP1 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP1", + (long) irel->r_offset); return FALSE; } @@ -9614,9 +9565,8 @@ nds32_elf_relax_longjump2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (i2_irelfn == irelend || cond_irelfn == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGJUMP2 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP2", + (long) irel->r_offset); return FALSE; } @@ -9807,9 +9757,8 @@ nds32_elf_relax_longjump3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (hi_irelfn == irelend || lo_irelfn == irelend || cond_irelfn == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGJUMP3 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP3", + (long) irel->r_offset); return FALSE; } @@ -9988,9 +9937,8 @@ nds32_elf_relax_longcall4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (hi_irel == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGCALL4 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL4", + (long) irel->r_offset); return FALSE; } @@ -10019,9 +9967,8 @@ nds32_elf_relax_longcall4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (ptr_irel == irelend || em_irel == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGCALL4 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL4", + (long) irel->r_offset); return FALSE; } /* Check these is enough space to insert jal in R_NDS32_EMPTY. */ @@ -10091,9 +10038,8 @@ nds32_elf_relax_longcall5 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, R_NDS32_25_PCREL_RELA, irel->r_addend); if (cond_irel == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGCALL5 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL5", + (long) irel->r_offset); return FALSE; } @@ -10170,9 +10116,8 @@ nds32_elf_relax_longcall6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (em_irel == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGCALL6 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL6", + (long) irel->r_offset); return FALSE; } @@ -10209,9 +10154,8 @@ nds32_elf_relax_longcall6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, R_NDS32_PTR_RESOLVED, irel->r_addend); if (cond_irel == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGCALL6 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, + "R_NDS32_LONGCALL6", (long) irel->r_offset); return FALSE; } cond_irel->r_addend = 1; @@ -10259,9 +10203,8 @@ nds32_elf_relax_longcall6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, R_NDS32_PTR_RESOLVED, irel->r_addend); if (cond_irel == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGCALL6 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, + "R_NDS32_LONGCALL6", (long) irel->r_offset); return FALSE; } cond_irel->r_addend = 1; @@ -10310,9 +10253,8 @@ nds32_elf_relax_longjump4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (hi_irel == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGJUMP4 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP4", + (long) irel->r_offset); return FALSE; } @@ -10333,9 +10275,8 @@ nds32_elf_relax_longjump4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (ptr_irel == irelend || em_irel == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGJUMP4 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP4", + (long) irel->r_offset); return FALSE; } @@ -10408,9 +10349,8 @@ nds32_elf_relax_longjump5 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, R_NDS32_25_PCREL_RELA, irel->r_addend); if (cond_irel == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGJUMP5 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP5", + (long) irel->r_offset); return FALSE; } @@ -10538,9 +10478,8 @@ nds32_elf_relax_longjump6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (em_irel == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGJUMP6 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP6", + (long) irel->r_offset); return FALSE; } @@ -10709,9 +10648,8 @@ nds32_elf_relax_longjump7 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, R_NDS32_15_PCREL_RELA, irel->r_addend); if (cond_irel == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LONGJUMP7 points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP7", + (long) irel->r_offset); return FALSE; } @@ -10784,7 +10722,8 @@ nds32_elf_relax_loadstore (struct bfd_link_info *link_info, bfd *abfd, bfd_byte *contents, Elf_Internal_Sym *isymbuf, Elf_Internal_Shdr *symtab_hdr, int load_store_relax) { - int eliminate_sethi = 0, range_type, i; + int eliminate_sethi = 0, range_type; + unsigned int i; bfd_vma local_sda, laddr; int seq_len; /* Original length of instruction sequence. */ uint32_t insn; @@ -10804,7 +10743,7 @@ nds32_elf_relax_loadstore (struct bfd_link_info *link_info, bfd *abfd, *insn_len = seq_len; /* Get the high part relocation. */ - for (i = 0; (unsigned) i < sizeof (checked_types); i++) + for (i = 0; i < ARRAY_SIZE (checked_types); i++) { hi_irelfn = find_relocs_at_address_addr (irel, internal_relocs, irelend, checked_types[i], laddr); @@ -10814,9 +10753,8 @@ nds32_elf_relax_loadstore (struct bfd_link_info *link_info, bfd *abfd, if (hi_irelfn == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_LOADSTORE points to unrecognized" - "reloc at 0x%lx.", abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LOADSTORE", + (long) irel->r_offset); return FALSE; } @@ -11227,6 +11165,7 @@ nds32_elf_relax_letlsls (struct bfd_link_info *link_info, bfd *abfd, success = 1; break; } + /* Fall through. */ case (N32_OP6_MEM << 8) | N32_MEM_LH: case (N32_OP6_MEM << 8) | N32_MEM_SH: case (N32_OP6_MEM << 8) | N32_MEM_LHS: @@ -11241,6 +11180,7 @@ nds32_elf_relax_letlsls (struct bfd_link_info *link_info, bfd *abfd, success = 1; break; } + /* Fall through. */ case (N32_OP6_MEM << 8) | N32_MEM_LW: case (N32_OP6_MEM << 8) | N32_MEM_SW: /* The range is +/-64k. */ @@ -11254,6 +11194,7 @@ nds32_elf_relax_letlsls (struct bfd_link_info *link_info, bfd *abfd, success = 1; break; } + /* Fall through. */ default: break; } @@ -11286,9 +11227,8 @@ nds32_elf_relax_ptr (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (re_irel == irelend) { - (*_bfd_error_handler) - ("%B: warning: R_NDS32_PTR points to unrecognized reloc at 0x%lx.", - abfd, (long) irel->r_offset); + _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_PTR", + (long) irel->r_offset); return FALSE; } @@ -11907,7 +11847,7 @@ nds32_elf_pick_relax (bfd_boolean init, asection *sec, bfd_boolean *again, break; case NDS32_RELAX_JUMP_IFC_ROUND: if (!nds32_elf_ifc_finish (link_info)) - (*_bfd_error_handler) (_("error: Jump IFC Fail.")); + _bfd_error_handler (_("error: Jump IFC Fail.")); if (table->target_optimize & NDS32_RELAX_EX9_ON) { pass++; @@ -11924,7 +11864,7 @@ nds32_elf_pick_relax (bfd_boolean init, asection *sec, bfd_boolean *again, { /* Do jump IFC optimization again. */ if (!nds32_elf_ifc_finish (link_info)) - (*_bfd_error_handler) (_("error: Jump IFC Fail.")); + _bfd_error_handler (_("error: Jump IFC Fail.")); } break; default: @@ -11967,7 +11907,7 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, * non-code section or * empty content or * no reloc entry. */ - if (link_info->relocatable + if (bfd_link_relocatable (link_info) || (sec->flags & SEC_RELOC) == 0 || (sec->flags & SEC_EXCLUDE) == 1 || (sec->flags & SEC_CODE) == 0 @@ -12035,7 +11975,7 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, /* Set the _ITB_BASE_. */ if (!nds32_elf_ex9_itb_base (link_info)) { - (*_bfd_error_handler) (_("%B: error: Cannot set _ITB_BASE_"), abfd); + _bfd_error_handler (_("%B: error: Cannot set _ITB_BASE_"), abfd); bfd_set_error (bfd_error_bad_value); } } @@ -12306,7 +12246,7 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, irelend, isymbuf)) goto error_return; - if (*again == FALSE) + if (!*again) { if (!nds32_fag_remove_unused_fpbase (abfd, sec, internal_relocs, irelend)) @@ -12316,7 +12256,7 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, nds32_elf_pick_relax (FALSE, sec, again, table, link_info); - if (*again == FALSE) + if (!*again) { if (!nds32_relax_adjust_label (abfd, sec, internal_relocs, contents, &relax_blank_list, optimize, opt_size)) @@ -12333,15 +12273,15 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, relax_blank_list = NULL; } - if (*again == FALSE) + if (!*again) { /* Closing the section, so we don't relax it anymore. */ bfd_vma sec_size_align; Elf_Internal_Rela *tmp_rel; /* Pad to alignment boundary. Only handle current section alignment. */ - sec_size_align = (sec->size + (~((-1) << sec->alignment_power))) - & ((-1) << sec->alignment_power); + sec_size_align = (sec->size + (~((-1U) << sec->alignment_power))) + & ((-1U) << sec->alignment_power); if ((sec_size_align - sec->size) & 0x2) { insn16 = NDS32_NOP16; @@ -12780,7 +12720,8 @@ nds32_relax_fp_as_gp (struct bfd_link_info *link_info, { /* Begin of the region. */ if (begin_rel) - (*_bfd_error_handler) (_("%B: Nested OMIT_FP in %A."), abfd, sec); + /* xgettext:c-format */ + _bfd_error_handler (_("%B: Nested OMIT_FP in %A."), abfd, sec); begin_rel = irel; nds32_fag_init (&fag_head); @@ -12798,7 +12739,8 @@ nds32_relax_fp_as_gp (struct bfd_link_info *link_info, if (begin_rel == NULL) { - (*_bfd_error_handler) (_("%B: Unmatched OMIT_FP in %A."), abfd, sec); + /* xgettext:c-format */ + _bfd_error_handler (_("%B: Unmatched OMIT_FP in %A."), abfd, sec); continue; } @@ -13057,25 +12999,22 @@ nds32_elf_get_relocated_section_contents (bfd *abfd, switch (r) { case bfd_reloc_undefined: - if (!((*link_info->callbacks->undefined_symbol) - (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr), - input_bfd, input_section, (*parent)->address, TRUE))) - goto error_return; + (*link_info->callbacks->undefined_symbol) + (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr), + input_bfd, input_section, (*parent)->address, TRUE); break; case bfd_reloc_dangerous: BFD_ASSERT (error_message != NULL); - if (!((*link_info->callbacks->reloc_dangerous) - (link_info, error_message, input_bfd, input_section, - (*parent)->address))) - goto error_return; + (*link_info->callbacks->reloc_dangerous) + (link_info, error_message, + input_bfd, input_section, (*parent)->address); break; case bfd_reloc_overflow: - if (!((*link_info->callbacks->reloc_overflow) - (link_info, NULL, - bfd_asymbol_name (*(*parent)->sym_ptr_ptr), - (*parent)->howto->name, (*parent)->addend, - input_bfd, input_section, (*parent)->address))) - goto error_return; + (*link_info->callbacks->reloc_overflow) + (link_info, NULL, + bfd_asymbol_name (*(*parent)->sym_ptr_ptr), + (*parent)->howto->name, (*parent)->addend, + input_bfd, input_section, (*parent)->address); break; case bfd_reloc_outofrange: /* PR ld/13730: @@ -13083,6 +13022,7 @@ nds32_elf_get_relocated_section_contents (bfd *abfd, complete binaries. Do not abort, but issue an error message instead. */ link_info->callbacks->einfo + /* xgettext:c-format */ (_("%X%P: %B(%A): relocation \"%R\" goes out of range\n"), abfd, input_section, * parent); goto error_return; @@ -14859,7 +14799,7 @@ nds32_elf_ex9_init (void) sizeof (struct elf_nds32_code_hash_entry), 1023)) { - (*_bfd_error_handler) (_("Linker: cannot init ex9 hash table error \n")); + _bfd_error_handler (_("Linker: cannot init ex9 hash table error \n")); return FALSE; } return TRUE; @@ -15009,7 +14949,6 @@ nds32_elf_ex9_import_table (struct bfd_link_info *info) { int num = 0; bfd_byte *contents; - unsigned long insn; FILE *ex9_import_file; int update_ex9_table; struct elf_nds32_link_hash_table *table; @@ -15023,6 +14962,7 @@ nds32_elf_ex9_import_table (struct bfd_link_info *info) /* Read instructions from the input file and build the list. */ while (!feof (ex9_import_file)) { + unsigned long insn; char *code; struct elf_nds32_insn_times_entry *ptr; size_t nread; @@ -15033,7 +14973,7 @@ nds32_elf_ex9_import_table (struct bfd_link_info *info) break; insn = bfd_getb32 (contents); code = bfd_malloc (sizeof (char) * 9); - snprintf (code, 9, "%08lx", insn); + snprintf (code, 9, "%08lx", (insn & 0xffffffff)); ptr = bfd_malloc (sizeof (struct elf_nds32_insn_times_entry)); ptr->string = code; ptr->order = num; @@ -15267,7 +15207,7 @@ nds32_elf_ex9_reloc_jmp (struct bfd_link_info *link_info) if (!nds32_get_section_contents (fix_ptr->sec->owner, fix_ptr->sec, &source_contents, TRUE)) - (*_bfd_error_handler) + _bfd_error_handler (_("Linker: error cannot fixed ex9 relocation \n")); if (temp_ptr->order < 32) insn_ex9 = INSN_EX9_IT_2; @@ -15281,7 +15221,7 @@ nds32_elf_ex9_reloc_jmp (struct bfd_link_info *link_info) else { if (!temp_ptr->next || temp_ptr->m_list != temp_ptr->next->m_list) - (*_bfd_error_handler) + _bfd_error_handler (_("Linker: error cannot fixed ex9 relocation \n")); else temp_ptr = temp_ptr->next; @@ -15491,10 +15431,11 @@ nds32_elf_ex9_build_hash_table (bfd *abfd, asection *sec, if (relocation & align) { /* Incorrect alignment. */ - (*_bfd_error_handler) - (_("%s: warning: unaligned small data access. " + _bfd_error_handler + /* xgettext:c-format */ + (_("%B: warning: unaligned small data access. " "For entry: {%d, %d, %d}, addr = 0x%x, align = 0x%x."), - bfd_get_filename (abfd), irel->r_offset, + abfd, irel->r_offset, irel->r_info, irel->r_addend, relocation, align); off += 4; continue; @@ -15524,7 +15465,7 @@ nds32_elf_ex9_build_hash_table (bfd *abfd, asection *sec, bfd_hash_lookup (&ex9_code_table, code, TRUE, TRUE); if (entry == NULL) { - (*_bfd_error_handler) + _bfd_error_handler (_("%P%F: failed creating ex9.it %s hash table: %E\n"), code); return FALSE; } @@ -15735,6 +15676,7 @@ nds32_elf_ex9_itb_base (struct bfd_link_info *link_info) #define elf_backend_may_use_rel_p 1 #define elf_backend_default_use_rela_p 1 #define elf_backend_may_use_rela_p 1 +#define elf_backend_dtrel_excludes_plt 1 #include "elf32-target.h"