[binutils-gdb] x86: Check invalid symbol name

H.J. Lu hjl@sourceware.org
Thu Oct 2 21:36:40 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bf7c1b207d84707b8bb99fb57122e3e58d3065fe

commit bf7c1b207d84707b8bb99fb57122e3e58d3065fe
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Sep 30 08:50:19 2025 +0800

    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 <hjl.tools@gmail.com>

Diff:
---
 bfd/elf32-i386.c   | 2 ++
 bfd/elf64-x86-64.c | 3 +++
 2 files changed, 5 insertions(+)

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;


More information about the Binutils-cvs mailing list