X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf32-nds32.c;h=d8726359d568f9a78ab83a5d545c5b97a7153912;hb=14962256b310efddf677ff4f5c9fa41047f48c39;hp=ee4eea7372ffc98989953c64ae86ce770962f7ab;hpb=190eb1ddba41aad3a31edead9392473ae9d3bbe3;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index ee4eea7372..d8726359d5 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -3874,40 +3874,6 @@ nds32_elf_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf_nds32_link_hash_entry *) dir; eind = (struct elf_nds32_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - if (ind->root.type == bfd_link_hash_indirect) - abort (); - - /* Add reloc counts against the weak sym to the strong sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL;) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect) { if (dir->got.refcount <= 0) @@ -3920,24 +3886,6 @@ nds32_elf_copy_indirect_symbol (struct bfd_link_info *info, _bfd_elf_link_hash_copy_indirect (info, dir, ind); } - -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -4023,7 +3971,7 @@ nds32_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (!readonly_dynrelocs (h)) + if (!_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; @@ -4304,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 = 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 @@ -4484,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); } } @@ -4588,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; @@ -4604,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) @@ -6513,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; } @@ -6583,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] */ @@ -6603,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)); } @@ -7133,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 =