diff options
author | Alan Modra <amodra@gmail.com> | 2023-03-06 10:42:51 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-03-06 13:11:10 +1030 |
commit | 86a2562b0958ed988e20a8b3a1b0029ff91dda3e (patch) | |
tree | 54031bf3c5db72554e1384d1bd88bfd53925a562 /binutils | |
parent | e3f450f3933ddb9ca4ef405722706f3c793d295e (diff) | |
download | gdb-86a2562b0958ed988e20a8b3a1b0029ff91dda3e.zip gdb-86a2562b0958ed988e20a8b3a1b0029ff91dda3e.tar.gz gdb-86a2562b0958ed988e20a8b3a1b0029ff91dda3e.tar.bz2 |
Downgrade nm fatal errors to non-fatal
Many of the fatal errors in nm ought to be recoverable. This patch
downgrades most of them. The ones that are left are most likely due
to memory allocation failures.
* nm.c (print_symdef_entry): Don't bomb with a fatal error
on a corrupted archive symbol table.
(filter_symbols): Silently omit symbols that return NULL
from bfd_minisymbol_to_symbol rather than giving a fatal
error.
(display_rel_file): Don't give a fatal error on
bfd_read_minisymbols returning an error, or on not being able
to read dynamic symbols for synth syms.
(display_archive): Downgrade bfd_openr_next_archived_file
error.
(display_file): Don't bomb on a bfd_close failure.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/nm.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/binutils/nm.c b/binutils/nm.c index 2c428d2..8b6b249 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -736,19 +736,19 @@ print_symdef_entry (bfd *abfd) idx != BFD_NO_MORE_SYMBOLS; idx = bfd_get_next_mapent (abfd, idx, &thesym)) { - bfd *elt; if (!everprinted) { printf (_("\nArchive index:\n")); everprinted = true; } - elt = bfd_get_elt_at_index (abfd, idx); - if (elt == NULL) - bfd_fatal ("bfd_get_elt_at_index"); - if (thesym->name != (char *) NULL) + if (thesym->name != NULL) { print_symname ("%s", NULL, thesym->name, abfd); - printf (" in %s\n", bfd_get_filename (elt)); + bfd *elt = bfd_get_elt_at_index (abfd, idx); + if (elt) + printf (" in %s\n", bfd_get_filename (elt)); + else + printf ("\n"); } } } @@ -781,9 +781,9 @@ filter_symbols (bfd *abfd, bool is_dynamic, void *minisyms, int keep = 0; asymbol *sym; - sym = bfd_minisymbol_to_symbol (abfd, is_dynamic, (const void *) from, store); + sym = bfd_minisymbol_to_symbol (abfd, is_dynamic, from, store); if (sym == NULL) - bfd_fatal (bfd_get_filename (abfd)); + continue; if (sym->name != NULL && sym->name[0] == '_' @@ -1405,19 +1405,7 @@ display_rel_file (bfd *abfd, bfd *archive_bfd) } symcount = bfd_read_minisymbols (abfd, dynamic, &minisyms, &size); - if (symcount < 0) - { - if (dynamic && bfd_get_error () == bfd_error_no_symbols) - { - if (!quiet) - non_fatal (_("%s: no symbols"), bfd_get_filename (abfd)); - return; - } - - bfd_fatal (bfd_get_filename (abfd)); - } - - if (symcount == 0) + if (symcount <= 0) { if (!quiet) non_fatal (_("%s: no symbols"), bfd_get_filename (abfd)); @@ -1449,7 +1437,7 @@ display_rel_file (bfd *abfd, bfd *archive_bfd) dyn_syms = (asymbol **) xmalloc (storage); dyn_count = bfd_canonicalize_dynamic_symtab (abfd, dyn_syms); if (dyn_count < 0) - bfd_fatal (bfd_get_filename (abfd)); + dyn_count = 0; } } @@ -1588,7 +1576,7 @@ display_archive (bfd *file) if (arfile == NULL) { if (bfd_get_error () != bfd_error_no_more_archived_files) - bfd_fatal (bfd_get_filename (file)); + bfd_nonfatal (bfd_get_filename (file)); break; } @@ -1664,7 +1652,7 @@ display_file (char *filename) free_lineno_cache (file); if (!bfd_close (file)) - bfd_fatal (filename); + retval = false; return retval; } |