From: Alan Modra Date: Fri, 30 May 2025 22:45:45 +0000 (+0930) Subject: Revert "Replace assertions with error return values, thus ensuring an illegal memory... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=47d7ab705754543cd8b2671aae134163f22852c8;p=thirdparty%2Fbinutils-gdb.git Revert "Replace assertions with error return values, thus ensuring an illegal memory access does not occur." This reverts commit 429fb15134cfbdafe2b203086ee05d827726b63b. --- diff --git a/bfd/elf-strtab.c b/bfd/elf-strtab.c index 52a0895fb43..9b0b0b8ec60 100644 --- a/bfd/elf-strtab.c +++ b/bfd/elf-strtab.c @@ -285,11 +285,12 @@ _bfd_elf_strtab_offset (struct elf_strtab_hash *tab, size_t idx) { struct elf_strtab_hash_entry *entry; - if (idx == 0 || idx >= tab->size || tab->sec_size == 0) + if (idx == 0) return 0; + BFD_ASSERT (idx < tab->size); + BFD_ASSERT (tab->sec_size); entry = tab->array[idx]; - if (entry == NULL || entry->refcount == 0) - return 0; + BFD_ASSERT (entry->refcount > 0); entry->refcount--; return tab->array[idx]->u.index; } diff --git a/bfd/elf.c b/bfd/elf.c index 61910f8909a..3073f860621 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -7161,12 +7161,9 @@ _bfd_elf_write_object_contents (bfd *abfd) { /* Don't set the sh_name field without section header. */ if ((abfd->flags & BFD_NO_SECTION_HEADER) == 0) - { - i_shdrp[count]->sh_name - = _bfd_elf_strtab_offset (elf_shstrtab (abfd), - i_shdrp[count]->sh_name); - /* FIXME: If we could not set the section name, should we tell the user ? */ - } + i_shdrp[count]->sh_name + = _bfd_elf_strtab_offset (elf_shstrtab (abfd), + i_shdrp[count]->sh_name); if (bed->elf_backend_section_processing) if (!(*bed->elf_backend_section_processing) (abfd, i_shdrp[count])) return false;