[PATCH] elf: Don't use corrupt string table
H.J. Lu
hjl.tools@gmail.com
Sun Sep 21 07:48:25 GMT 2025
On Fri, Sep 19, 2025 at 7:59 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> 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
>
Any comments or objections?
--
H.J.
More information about the Binutils
mailing list