From: H.J. Lu Date: Tue, 30 Sep 2025 00:50:19 +0000 (+0800) Subject: x86: Check invalid symbol name X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bf7c1b207d84707b8bb99fb57122e3e58d3065fe;p=thirdparty%2Fbinutils-gdb.git x86: Check invalid symbol name 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 --- diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index e375e18d5fe..507a0762aff 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -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; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 236cff97346..620b6a380cd 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -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;