]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86: Check invalid symbol name
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 30 Sep 2025 00:50:19 +0000 (08:50 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 2 Oct 2025 21:32:18 +0000 (05:32 +0800)
Since bfd_elf_sym_name returns bfd_symbol_error_name for invalid symbol,
name, return error if bfd_elf_sym_name returns bfd_symbol_error_name.

PR ld/33501
* elf32-i386.c (elf_i386_scan_relocs): Return error for invalid
symbol name.
* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
bfd/elf32-i386.c
bfd/elf64-x86-64.c

index e375e18d5fee279bb34f0f1f1939285ee0607c37..507a0762aff2494f4de44e6ac4a0a2d3145fb58a 100644 (file)
@@ -1607,6 +1607,8 @@ elf_i386_scan_relocs (bfd *abfd,
              /* Fake a STT_GNU_IFUNC symbol.  */
              h->root.root.string = bfd_elf_sym_name (abfd, symtab_hdr,
                                                      isym, NULL);
+             if (h->root.root.string == bfd_symbol_error_name)
+               goto error_return;
              h->type = STT_GNU_IFUNC;
              h->def_regular = 1;
              h->ref_regular = 1;
index 236cff9734684db2eba4ac48b522b0b9a45c40e9..620b6a380cd002d3060357a1f12d82eeb308885d 100644 (file)
@@ -2590,6 +2590,9 @@ elf_x86_64_scan_relocs (bfd *abfd, struct bfd_link_info *info,
              /* Fake a STT_GNU_IFUNC symbol.  */
              h->root.root.string = bfd_elf_sym_name (abfd, symtab_hdr,
                                                      isym, NULL);
+             if (h->root.root.string == bfd_symbol_error_name)
+               goto error_return;
+
              h->type = STT_GNU_IFUNC;
              h->def_regular = 1;
              h->ref_regular = 1;