X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf32-nds32.c;h=d8726359d568f9a78ab83a5d545c5b97a7153912;hb=14962256b310efddf677ff4f5c9fa41047f48c39;hp=4f7ea764691f81408cc50c78e471cf7d4c8e56dd;hpb=ad172eaa4f5ff973890a6c37574946cecf0668b0;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index 4f7ea76469..d8726359d5 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -4252,33 +4252,6 @@ elf32_nds32_add_dynreloc (bfd *output_bfd, bfd_elf32_swap_reloca_out (output_bfd, rel, loc); } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Set the sizes of the dynamic sections. */ static bfd_boolean @@ -4432,12 +4405,14 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If we're not using lazy TLS relocations, don't generate the PLT and GOT entries they require. */ - if (!(info->flags & DF_BIND_NOW)) + if ((info->flags & DF_BIND_NOW)) + htab->root.tlsdesc_plt = 0; + else { - htab->dt_tlsdesc_got = htab->root.sgot->size; + htab->root.tlsdesc_got = htab->root.sgot->size; htab->root.sgot->size += 4; - htab->dt_tlsdesc_plt = htab->root.splt->size; + htab->root.tlsdesc_plt = htab->root.splt->size; htab->root.splt->size += 4 * ARRAY_SIZE (dl_tlsdesc_lazy_trampoline); } } @@ -4536,7 +4511,7 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, if (htab->tls_desc_trampoline && plt) { - if (htab->dt_tlsdesc_plt + if (htab->root.tlsdesc_plt && (!add_dynamic_entry (DT_TLSDESC_PLT, 0) || !add_dynamic_entry (DT_TLSDESC_GOT, 0))) return FALSE; @@ -4552,7 +4527,8 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->root, maybe_set_textrel, + elf_link_hash_traverse (&htab->root, + _bfd_elf_maybe_set_textrel, (void *) info); if ((info->flags & DF_TEXTREL) != 0) @@ -6461,14 +6437,14 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) case DT_TLSDESC_PLT: s = htab->root.splt; dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset - + htab->dt_tlsdesc_plt); + + htab->root.tlsdesc_plt); bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; case DT_TLSDESC_GOT: s = htab->root.sgot; dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset - + htab->dt_tlsdesc_got); + + htab->root.tlsdesc_got); bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; } @@ -6531,14 +6507,14 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) PLT_ENTRY_SIZE; } - if (htab->dt_tlsdesc_plt) + if (htab->root.tlsdesc_plt) { /* Calculate addresses. */ asection *sgot = sgot = ehtab->sgot; bfd_vma pltgot = sgotplt->output_section->vma + sgotplt->output_offset; bfd_vma tlsdesc_got = sgot->output_section->vma + sgot->output_offset - + htab->dt_tlsdesc_got; + + htab->root.tlsdesc_got; /* Get GP offset. */ pltgot -= elf_gp (output_bfd) - 4; /* PLTGOT[1] */ @@ -6551,7 +6527,7 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) dl_tlsdesc_lazy_trampoline[5] += 0xfff & pltgot; /* Insert .plt. */ - nds32_put_trampoline (splt->contents + htab->dt_tlsdesc_plt, + nds32_put_trampoline (splt->contents + htab->root.tlsdesc_plt, dl_tlsdesc_lazy_trampoline, ARRAY_SIZE (dl_tlsdesc_lazy_trampoline)); } @@ -7081,15 +7057,6 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, return TRUE; } - /* Don't do anything special with non-loaded, non-alloced sections. - In particular, any relocs in such sections should not affect GOT - and PLT reference counting (ie. we don't allow them to create GOT - or PLT entries), there's no possibility or desire to optimize TLS - relocs, and there's not much point in propagating relocs to shared - libs that the dynamic linker won't relocate. */ - if ((sec->flags & SEC_ALLOC) == 0) - return TRUE; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; sym_hashes = elf_sym_hashes (abfd); sym_hashes_end =