From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id D7BAB385B515 for ; Mon, 6 Mar 2023 03:28:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7BAB385B515 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-x633.google.com with SMTP id i5so8830167pla.2 for ; Sun, 05 Mar 2023 19:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678073330; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=XtroAsliKKqZyNfrMF7GjDI2EHFSA/MmCS+YU67MAro=; b=Vy2pH91Pz5XIg33K2f0NROt0kdOwlV8ZaCdfTbnC9DuOTKxsvUS4onBjAkVeQGt21u mG16s6JkbiAZsuxhWI1Ry4OGUqQyHB7wg1yyNrnbYu/2DKJ6wlac8PBKvijcMqNbuLGu HzBhv7DQIbR6pvr9Cu7tzu+6CROErAfIP9ZCw9yJg2xKi4F12Z7z4hh9JCvO2f5qO6VV LbmOojoUTjA/52BnZOWS8H3n94cvsRFNsJk8JSP9uQg4SeVlVn+hrCwtL33ds9GeKTjP tTR1WWs+Sng0arNCN2aJ6dvBiJeaCC0uujPbC11UkHvENCnkjGu+7Wu6PV99ZFSkhd2a EHTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678073330; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XtroAsliKKqZyNfrMF7GjDI2EHFSA/MmCS+YU67MAro=; b=jckOC802KL2tw3nk08EvVc0xyp+knanxk4YeTXqePAgZ5sDGqf78JjhxwG213C9QKU JL/eyuo3uNJZvVQRSlQqSItVAKh2l2J7sigipt7yR2SrU/27QzYwKYI0ZWFHkmjQt3Rt 4U+eJKiYQtXgQVAxns4q2Kf3o7UiFQiUrpT/bVFtQaaPi4ZgOOrRGdc5R5KoPvzdG6zG Qw+5cnOlWJ3i2pHqS522C2izjnvZOwEgTldCK0WaBzk6TKNyiQZ33Ef5PnT3O87a7AT6 FM/Lkx04Hrwd2wHXj6SNd5zSbqKcesejjxYhLZU4Xjx5W4HJk+Yt52G+h1nBlbrj2Lg/ j2ew== X-Gm-Message-State: AO0yUKWYdZlV74Ek5SG+oOU+XcPeTu3XeuQLEHQLZ7QsAOCkEt8HrqZ3 319ng78U272yezumGAf/rMZCBOOheRA= X-Google-Smtp-Source: AK7set9hhjes2bUtFJgsbTUPZqGtGFXrTP8P7Ifd5w26qi/W3DNrPtYUToFqklh4EX0PyJPyAoXOIw== X-Received: by 2002:a17:902:d4cd:b0:19e:23c1:4c3d with SMTP id o13-20020a170902d4cd00b0019e23c14c3dmr11959038plg.2.1678073329719; Sun, 05 Mar 2023 19:28:49 -0800 (PST) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id z15-20020a170902d54f00b0019a928a8982sm5418386plf.118.2023.03.05.19.28.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Mar 2023 19:28:49 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 3E3361142C90; Mon, 6 Mar 2023 13:58:47 +1030 (ACDT) Date: Mon, 6 Mar 2023 13:58:47 +1030 From: Alan Modra To: binutils@sourceware.org Subject: Downgrade nm fatal errors to non-fatal Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3035.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. diff --git a/binutils/nm.c b/binutils/nm.c index 2c428d20fdf..8b6b249a951 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; } -- Alan Modra Australia Development Lab, IBM