+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.
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
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[] =
{"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},
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\
{
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;
}
}
{
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;
}
if (symcount == 0)
{
- non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
+ if (!quiet)
+ non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
return;
}
case OPTION_WITH_SYMBOL_VERSIONS:
/* Ignored for backward compatibility. */
break;
+ case OPTION_QUIET:
+ quiet = 1;
+ break;
case 'D':
dynamic = 1;
break;