]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Re: elf: Disallow the empty global symbol name
authorAlan Modra <amodra@gmail.com>
Thu, 25 Sep 2025 01:11:32 +0000 (10:41 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 25 Sep 2025 01:14:12 +0000 (10:44 +0930)
sparc64-linux-gnu  +FAIL: selective2
sparc64-linux-gnu  +FAIL: selective3

PR ld/33456
* elflink.c (elf_link_add_object_symbols): Move new check later
to give the backend add_symbol_hook a chance to remove symbols
with empty names.

bfd/elflink.c

index 0a0456177c2c07aee25224416c0a89f5f71866ef..5c8b822e36ad3fe85e4b9b20d2e5feaa3d399f2e 100644 (file)
@@ -5096,13 +5096,6 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
       if (name == NULL)
        goto error_free_vers;
 
-      if (name[0] == '\0')
-       {
-         _bfd_error_handler (_("%pB: corrupt symbol table"), abfd);
-         bfd_set_error (bfd_error_bad_value);
-         goto error_free_vers;
-       }
-
       if (isym->st_shndx == SHN_COMMON
          && (abfd->flags & BFD_PLUGIN) != 0)
        {
@@ -5146,6 +5139,13 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
            continue;
        }
 
+      if (name[0] == '\0')
+       {
+         _bfd_error_handler (_("%pB: corrupt symbol table"), abfd);
+         bfd_set_error (bfd_error_bad_value);
+         goto error_free_vers;
+       }
+
       /* Sanity check that all possibilities were handled.  */
       if (sec == NULL)
        abort ();