]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Revert "Replace assertions with error return values, thus ensuring an illegal memory...
authorAlan Modra <amodra@gmail.com>
Fri, 30 May 2025 22:45:45 +0000 (08:15 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 30 May 2025 22:46:41 +0000 (08:16 +0930)
This reverts commit 429fb15134cfbdafe2b203086ee05d827726b63b.

bfd/elf-strtab.c
bfd/elf.c

index 52a0895fb43eb85737f48f70559b55a7f74abb54..9b0b0b8ec60548a85d9c189a651b66adf09698c4 100644 (file)
@@ -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;
 }
index 61910f8909acde5400bc27afd13cc82d7663eb72..3073f860621f390dd5f6dabb8795bb8f6ec36c6f 100644 (file)
--- 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;