Revised "Don't return (null) from bfd_elf_sym_name"

Commit 68bbe11833 results in a lot of follow up work, much of which
likely is still to be done. (And yes, since this is all for corrupted
or fuzzed object files, a whole lot of work doesn't much benefit
anyone.  It was a bad idea to put NULL in asymbol->name.)  So I'm
changing the approach to instead put a unique empty string for symbols
with a corrupted st_name.  An empty string won't require much work to
ensure nm, objcopy, objdump etc. won't crash, since these tools
already must work with unnamed local symbols.

The unique empty string is called bfd_symbol_error_name.  This patch
uses that name string for corrupted symbols in the ELF and COFF
backends.  Such symbols are displayed by nm and objdump as the
translated string "<corrupt>", which is what the COFF backend used to
put directly into corrupted symbols.

ie. it's the way I should have written the original patch, plus a few
tides and cleanups I retained from the reverted patches.
This commit is contained in:
Alan Modra
2024-10-08 10:05:39 +10:30
parent cc516199d6
commit 124deb3101
12 changed files with 97 additions and 58 deletions

View File

@@ -4895,9 +4895,6 @@ ld_is_local_symbol (asymbol * sym)
if (name == NULL || *name == 0)
return false;
if (strcmp (name, "(null)") == 0)
return false;
/* Skip .Lxxx and such like. */
if (bfd_is_local_label (link_info.output_bfd, sym))
return false;