[PATCH] elf: Don't use corrupt string table
H.J. Lu
hjl.tools@gmail.com
Thu Sep 18 23:59:35 GMT 2025
Return NULL for corrupt string table to avoid linker crash later.
PR ld/33451
* elf.c (bfd_elf_get_str_section): Return NULL for corrupt string
table.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
bfd/elf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/bfd/elf.c b/bfd/elf.c
index 6ef60301091..f72b9da6570 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -363,7 +363,8 @@ bfd_elf_get_str_section (bfd *abfd, unsigned int shindex)
_bfd_error_handler
/* xgettext:c-format */
(_("%pB: string table [%u] is corrupt"), abfd, shindex);
- shstrtab[shstrtabsize - 1] = 0;
+ /* Don't use corrupt string table: PR ld/33451. */
+ return NULL;
}
i_shdrp[shindex]->contents = shstrtab;
}
--
2.51.0
More information about the Binutils
mailing list