X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Felf32-s390.c;h=5bd63fe1c942a7aa48a1c8c514312662d684845d;hb=refs%2Fheads%2Fconcurrent-displaced-stepping-2020-04-01;hp=d0771042f48ba9c0080f6ca9b71219c87c1320ed;hpb=f3185997ac0951edac802e29df03dfc0844fda34;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index d0771042f4..5bd63fe1c9 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -1,5 +1,5 @@ /* IBM S/390-specific support for 32-bit ELF - Copyright (C) 2000-2018 Free Software Foundation, Inc. + Copyright (C) 2000-2020 Free Software Foundation, Inc. Contributed by Carl B. Pedersen and Martin Schwidefsky. This file is part of BFD, the Binary File Descriptor library. @@ -654,9 +654,6 @@ struct elf_s390_link_hash_entry { struct elf_link_hash_entry elf; - /* Track dynamic relocs copied for this symbol. */ - struct elf_dyn_relocs *dyn_relocs; - /* Number of GOTPLT references for a function. */ bfd_signed_vma gotplt_refcount; @@ -787,7 +784,6 @@ link_hash_newfunc (struct bfd_hash_entry *entry, struct elf_s390_link_hash_entry *eh; eh = (struct elf_s390_link_hash_entry *) entry; - eh->dyn_relocs = NULL; eh->gotplt_refcount = 0; eh->tls_type = GOT_UNKNOWN; eh->ifunc_resolver_address = 0; @@ -803,7 +799,7 @@ static struct bfd_link_hash_table * elf_s390_link_hash_table_create (bfd *abfd) { struct elf_s390_link_hash_table *ret; - bfd_size_type amt = sizeof (struct elf_s390_link_hash_table); + size_t amt = sizeof (struct elf_s390_link_hash_table); ret = (struct elf_s390_link_hash_table *) bfd_zmalloc (amt); if (ret == NULL) @@ -832,37 +828,6 @@ elf_s390_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf_s390_link_hash_entry *) dir; eind = (struct elf_s390_link_hash_entry *) ind; - if (eind->dyn_relocs != NULL) - { - if (edir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &eind->dyn_relocs; (p = *pp) != NULL; ) - { - struct elf_dyn_relocs *q; - - for (q = edir->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 = edir->dyn_relocs; - } - - edir->dyn_relocs = eind->dyn_relocs; - eind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect && dir->got.refcount <= 0) { @@ -1306,7 +1271,7 @@ elf_s390_check_relocs (bfd *abfd, relocations we need for this symbol. */ if (h != NULL) { - head = &((struct elf_s390_link_hash_entry *) h)->dyn_relocs; + head = &h->dyn_relocs; } else { @@ -1332,7 +1297,7 @@ elf_s390_check_relocs (bfd *abfd, p = *head; if (p == NULL || p->sec != sec) { - bfd_size_type amt = sizeof *p; + size_t amt = sizeof *p; p = ((struct elf_dyn_relocs *) bfd_alloc (htab->elf.dynobj, amt)); @@ -1366,9 +1331,7 @@ elf_s390_check_relocs (bfd *abfd, /* This relocation describes which C++ vtable entries are actually used. Record for later use during GC. */ case R_390_GNU_VTENTRY: - BFD_ASSERT (h != NULL); - if (h != NULL - && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) + if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) return FALSE; break; @@ -1423,23 +1386,6 @@ elf_s390_adjust_gotplt (struct elf_s390_link_hash_entry *h) h->gotplt_refcount = -1; } -/* 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 = elf_s390_hash_entry (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 @@ -1462,11 +1408,9 @@ elf_s390_adjust_dynamic_symbol (struct bfd_link_info *info, { bfd_size_type pc_count = 0, count = 0; struct elf_dyn_relocs **pp; - struct elf_s390_link_hash_entry *eh; struct elf_dyn_relocs *p; - eh = (struct elf_s390_link_hash_entry *) h; - for (pp = &eh->dyn_relocs; (p = *pp) != NULL; ) + for (pp = &h->dyn_relocs; (p = *pp) != NULL; ) { pc_count += p->pc_count; p->count -= p->pc_count; @@ -1566,7 +1510,7 @@ elf_s390_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 (ELIMINATE_COPY_RELOCS && !readonly_dynrelocs (h)) + if (ELIMINATE_COPY_RELOCS && !_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; @@ -1614,7 +1558,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) { struct bfd_link_info *info; struct elf_s390_link_hash_table *htab; - struct elf_s390_link_hash_entry *eh = (struct elf_s390_link_hash_entry *)h; struct elf_dyn_relocs *p; if (h->root.type == bfd_link_hash_indirect) @@ -1745,7 +1688,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) else h->got.offset = (bfd_vma) -1; - if (eh->dyn_relocs == NULL) + if (h->dyn_relocs == NULL) return TRUE; /* In the shared -Bsymbolic case, discard space allocated for @@ -1760,7 +1703,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) { struct elf_dyn_relocs **pp; - for (pp = &eh->dyn_relocs; (p = *pp) != NULL; ) + for (pp = &h->dyn_relocs; (p = *pp) != NULL; ) { p->count -= p->pc_count; p->pc_count = 0; @@ -1773,12 +1716,12 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) /* Also discard relocs on undefined weak syms with non-default visibility. */ - if (eh->dyn_relocs != NULL + if (h->dyn_relocs != NULL && h->root.type == bfd_link_hash_undefweak) { if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT || UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)) - eh->dyn_relocs = NULL; + h->dyn_relocs = NULL; /* Make sure undefined weak symbols are output as a dynamic symbol in PIEs. */ @@ -1818,13 +1761,13 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) goto keep; } - eh->dyn_relocs = NULL; + h->dyn_relocs = NULL; keep: ; } /* Finally, allocate space. */ - for (p = eh->dyn_relocs; p != NULL; p = p->next) + for (p = h->dyn_relocs; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->sec)->sreloc; @@ -1834,33 +1777,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) return TRUE; } -/* 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 @@ -2005,7 +1921,7 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* Strip this section if we don't need it; see the comment below. */ } - else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) + else if (CONST_STRNEQ (bfd_section_name (s), ".rela")) { if (s->size != 0) relocs = TRUE; @@ -2084,7 +2000,8 @@ elf_s390_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->elf, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->elf, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { @@ -2165,7 +2082,11 @@ elf_s390_relocate_section (bfd *output_bfd, Elf_Internal_Rela *rel; Elf_Internal_Rela *relend; - BFD_ASSERT (is_s390_elf (input_bfd)); + if (!is_s390_elf (input_bfd)) + { + bfd_set_error (bfd_error_wrong_format); + return FALSE; + } htab = elf_s390_hash_table (info); symtab_hdr = &elf_symtab_hdr (input_bfd); @@ -2605,6 +2526,9 @@ elf_s390_relocate_section (bfd *output_bfd, case R_390_8: case R_390_16: case R_390_32: + if ((input_section->flags & SEC_ALLOC) == 0) + break; + if (h != NULL && s390_is_ifunc_symbol_p (h) && h->def_regular) @@ -2666,9 +2590,6 @@ elf_s390_relocate_section (bfd *output_bfd, } } - if ((input_section->flags & SEC_ALLOC) == 0) - break; - if ((bfd_link_pic (info) && (h == NULL || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT @@ -3252,7 +3173,7 @@ elf_s390_relocate_section (bfd *output_bfd, if (name == NULL) return FALSE; if (*name == '\0') - name = bfd_section_name (input_bfd, sec); + name = bfd_section_name (sec); } if (r == bfd_reloc_overflow) @@ -3942,7 +3863,7 @@ elf_s390_write_core_note (bfd *abfd, char *buf, int *bufsiz, case NT_PRPSINFO: { - char data[124] = { 0 }; + char data[124] ATTRIBUTE_NONSTRING = { 0 }; const char *fname, *psargs; va_start (ap, note_type); @@ -3951,7 +3872,18 @@ elf_s390_write_core_note (bfd *abfd, char *buf, int *bufsiz, va_end (ap); strncpy (data + 28, fname, 16); +#if GCC_VERSION == 8000 || GCC_VERSION == 8001 + DIAGNOSTIC_PUSH; + /* GCC 8.0 and 8.1 warn about 80 equals destination size with + -Wstringop-truncation: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 + */ + DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION; +#endif strncpy (data + 44, psargs, 80); +#if GCC_VERSION == 8000 || GCC_VERSION == 8001 + DIAGNOSTIC_POP; +#endif return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type, &data, sizeof (data)); } @@ -4049,7 +3981,6 @@ elf32_s390_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) #define elf_backend_grok_psinfo elf_s390_grok_psinfo #define elf_backend_write_core_note elf_s390_write_core_note #define elf_backend_plt_sym_val elf_s390_plt_sym_val -#define elf_backend_add_symbol_hook elf_s390_add_symbol_hook #define elf_backend_sort_relocs_p elf_s390_elf_sort_relocs_p #define bfd_elf32_mkobject elf_s390_mkobject