]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Don't return "(null)" from bfd_elf_sym_name
authorAlan Modra <amodra@gmail.com>
Tue, 1 Oct 2024 04:38:08 +0000 (14:08 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 3 Oct 2024 03:01:45 +0000 (12:31 +0930)
commit68bbe118337939aa0b52e007a7415c8a157579a1
tree71b25a79d7662c93097e0e1dddf34de5f69fcf28
parenta3aa9cb83fd2576c78031f7f052ec74965d9178f
Don't return "(null)" from bfd_elf_sym_name

A NULL return from bfd_elf_string_from_elf_section indicates an error.
That shouldn't be masked by bfd_elf_sym_name but rather passed up to
callers such as group_signature.  If we want to print "(null)" then
that should be done at a higher level.  That's what this patch does,
except that I chose to print "<null>" instead, like readelf.  If we
see "(null)" we're probably passing a NULL to printf.  I haven't
changed aoutx.h or pdp11.c print_symbol functions because they already
handle NULL names by omitting the name.  I also haven't changed
mach-o.c, mmo.c, som.c, srec.c, tekhex.c, vms-alpha.c and
wasm-module.c print_symbol function because it looks like they will
never have NULL symbol names.

bfd/
* elf.c (bfd_elf_sym_name): Don't turn a NULL name into a
pointer to "(null)".
(bfd_elf_print_symbol): Print "<null>" for NULL symbol names.
* coffgen.c (coff_print_symbol): Likewise.
* ecoff.c (_bfd_ecoff_print_symbol): Likewise.
* pef.c (bfd_pef_print_symbol): Likewise.
* syms.c (bfd_symbol_info): Return "<null>" in symbol_info.name
if symbol name is NULL.
ld/
* ldlang.c (ld_is_local_symbol): Don't check for "(null)"
symbol name.
bfd/coffgen.c
bfd/ecoff.c
bfd/elf.c
bfd/pef.c
bfd/syms.c
ld/ldlang.c