]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
nm: Add --quiet to suppress "no symbols" diagnostic
authorFangrui Song <maskray@google.com>
Fri, 26 Feb 2021 17:25:45 +0000 (09:25 -0800)
committerFangrui Song <maskray@google.com>
Fri, 26 Feb 2021 17:26:41 +0000 (09:26 -0800)
PR binutils/27408
* readelf.c (quiet): New option flag.
(enum long_option_values): New enum to hold long option value.
(long_options): Add --quiet.
(usage): Mention --quiet.
(display_rel_file): If quiet is enabled, suppress "no symbols".
(main): Handle the new option.
* NEWS: Mention --quiet.
* docs/binutils.texi: Document --quiet.

binutils/ChangeLog
binutils/NEWS
binutils/doc/binutils.texi
binutils/nm.c

index 0a89ac2f914a29b5c9aa20d7f8b58b305304b5e0..4289eb5e83d05b8e4160b6a37a009d1b4cad47c9 100644 (file)
@@ -1,3 +1,15 @@
+2021-02-26  Fangrui Song  <maskray@google.com>
+
+       PR 27408
+       * readelf.c (quiet): New option flag.
+       (enum long_option_values): New enum to hold long option value.
+       (long_options): Add --quiet.
+       (usage): Mention --quiet.
+       (display_rel_file): If quiet is enabled, suppress "no symbols".
+       (main): Handle the new option.
+       * NEWS: Mention --quiet.
+       * docs/binutils.texi: Document --quiet.
+
 2021-02-26  Tom de Vries  <tdevries@suse.de>
 
        * dwarf.c (display_debug_addr): Handle dwarf-5 .debug_addr bits.
index 61aca952f2de69dcd67d94d1456cc6138fa11271..d66944e95e04582af50104bd63bc4b13515e9aae 100644 (file)
@@ -10,6 +10,9 @@
   restored by the use of the --enable-follow-debug-links=no configure time
   option.
 
+* Nm has a new command line option: --quiet.  This suppresses "no symbols"
+  diagnostic.
+
 Changes in 2.36:
 
 * Update elfedit and readelf with LAM_U48 and LAM_U57 support.
index 94ea5720be8d7a7e6f8dfd86e56a1ccbaffe5bce..b7740dfc8a4f50b7d50d3bdb0d95ea86b38197eb 100644 (file)
@@ -4741,6 +4741,7 @@ readelf [@option{-a}|@option{--all}]
         [@option{-s}|@option{--syms}|@option{--symbols}]
         [@option{--dyn-syms}|@option{--lto-syms}]
         [@option{--demangle@var{=style}}|@option{--no-demangle}]
+        [@option{--quiet}]
         [@option{--recurse-limit}|@option{--no-recurse-limit}]
         [@option{-n}|@option{--notes}]
         [@option{-r}|@option{--relocs}]
@@ -4822,6 +4823,10 @@ file.
 Displays the information contained in the file's segment headers, if it
 has any.
 
+@item --quiet
+@cindex quiet
+Suppress "no symbols" diagnostic.
+
 @item -S
 @itemx --sections
 @itemx --section-headers
index acfdf665c035665dd5b2735daea2ca7538d5db10..a51d2eff75d70f6b66a953e31665e2634eb2b46a 100644 (file)
@@ -161,6 +161,7 @@ static int show_version = 0;        /* Show the version number.  */
 static int show_synthetic = 0; /* Display synthesized symbols too.  */
 static int line_numbers = 0;   /* Print line numbers for symbols.  */
 static int allow_special_symbols = 0;  /* Allow special symbols.  */
+static int quiet = 0;          /* Suppress "no symbols" diagnostic.  */
 
 /* The characters to use for global and local ifunc symbols.  */
 #if DEFAULT_F_FOR_IFUNC_SYMBOLS
@@ -200,7 +201,8 @@ enum long_option_values
   OPTION_RECURSE_LIMIT,
   OPTION_NO_RECURSE_LIMIT,
   OPTION_IFUNC_CHARS,
-  OPTION_WITH_SYMBOL_VERSIONS
+  OPTION_WITH_SYMBOL_VERSIONS,
+  OPTION_QUIET
 };
 
 static struct option long_options[] =
@@ -224,6 +226,7 @@ static struct option long_options[] =
   {"print-armap", no_argument, &print_armap, 1},
   {"print-file-name", no_argument, 0, 'o'},
   {"print-size", no_argument, 0, 'S'},
+  {"quiet", no_argument, 0, OPTION_QUIET},
   {"radix", required_argument, 0, 't'},
   {"recurse-limit", no_argument, NULL, OPTION_RECURSE_LIMIT},
   {"recursion-limit", no_argument, NULL, OPTION_RECURSE_LIMIT},
@@ -279,6 +282,7 @@ usage (FILE *stream, int status)
   fprintf (stream, _("\
   -S, --print-size       Print size of defined symbols\n\
   -s, --print-armap      Include index for symbols from archive members\n\
+      --quiet            Suppress \"no symbols\" diagnostic\n\
       --size-sort        Sort symbols by size\n\
       --special-syms     Include special symbols in the output\n\
       --synthetic        Display synthetic symbols as well\n\
@@ -1130,7 +1134,8 @@ display_rel_file (bfd *abfd, bfd *archive_bfd)
     {
       if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
        {
-         non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
+         if (!quiet)
+           non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
          return;
        }
     }
@@ -1140,7 +1145,8 @@ display_rel_file (bfd *abfd, bfd *archive_bfd)
     {
       if (dynamic && bfd_get_error () == bfd_error_no_symbols)
        {
-         non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
+         if (!quiet)
+           non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
          return;
        }
 
@@ -1149,7 +1155,8 @@ display_rel_file (bfd *abfd, bfd *archive_bfd)
 
   if (symcount == 0)
     {
-      non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
+      if (!quiet)
+       non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
       return;
     }
 
@@ -1776,6 +1783,9 @@ main (int argc, char **argv)
        case OPTION_WITH_SYMBOL_VERSIONS:
          /* Ignored for backward compatibility.  */
          break;
+       case OPTION_QUIET:
+         quiet = 1;
+         break;
        case 'D':
          dynamic = 1;
          break;