* [PATCH] nm: Add --quiet to suppress "no symbols" diagnostic
@ 2021-02-12 18:16 Fangrui Song
2021-02-23 4:20 ` Fangrui Song
0 siblings, 1 reply; 2+ messages in thread
From: Fangrui Song @ 2021-02-12 18:16 UTC (permalink / raw)
To: binutils; +Cc: Fangrui Song
PR binutils/27408
* readelf.c (quiet): New option flag.
(display_rel_file): If quiet is enabled, suppress "no symbols".
(enum long_option_values): New enum to hold long option value.
(options): Add quiet.
(main): Handle the new option.
* NEWS: Mention the new feature.
* docs/binutils.texi: Document the new feature.
---
binutils/NEWS | 3 +++
binutils/doc/binutils.texi | 5 +++++
binutils/nm.c | 17 +++++++++++++----
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/binutils/NEWS b/binutils/NEWS
index b0d55623738..3e4c39b1395 100644
--- a/binutils/NEWS
+++ b/binutils/NEWS
@@ -7,6 +7,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.
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index 94ea5720be8..b7740dfc8a4 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -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
diff --git a/binutils/nm.c b/binutils/nm.c
index acfdf665c03..c366d8a5de7 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -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},
@@ -1130,7 +1133,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 +1144,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 +1154,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 +1782,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;
--
2.30.0.478.g8a0d178c01-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] nm: Add --quiet to suppress "no symbols" diagnostic
2021-02-12 18:16 [PATCH] nm: Add --quiet to suppress "no symbols" diagnostic Fangrui Song
@ 2021-02-23 4:20 ` Fangrui Song
0 siblings, 0 replies; 2+ messages in thread
From: Fangrui Song @ 2021-02-23 4:20 UTC (permalink / raw)
To: binutils
On 2021-02-12, Fangrui Song via Binutils wrote:
> PR binutils/27408
> * readelf.c (quiet): New option flag.
> (display_rel_file): If quiet is enabled, suppress "no symbols".
> (enum long_option_values): New enum to hold long option value.
> (options): Add quiet.
> (main): Handle the new option.
> * NEWS: Mention the new feature.
> * docs/binutils.texi: Document the new feature.
Ping
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-23 4:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-12 18:16 [PATCH] nm: Add --quiet to suppress "no symbols" diagnostic Fangrui Song
2021-02-23 4:20 ` Fangrui Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).