mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-27 09:38:57 +00:00
Add the ability for nm to display symbol version information.
PR binutils/20751 * nm.c (with_symbol_versions): New local variable. (long_options): Add --with-symbol-versions. (usage): Mention --with-symbol-versions. (print_symbol): If with_symbol_versions is set then display the version information associated with the symbol. * NEWS: Mention the new feature. * doc/binutils.texi (nm): Document the new option. (objdump): Describe how symbol version information is displayed for dynamic symbol dumps. (readelf): Describe how symbol version information is displayed. * testsuite/binutils-all/nm.exp: Add a test of the new feature.
This commit is contained in:
@@ -161,6 +161,7 @@ static int show_stats = 0; /* Show statistics. */
|
||||
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 with_symbol_versions = 0; /* Include symbol version information in the output. */
|
||||
|
||||
/* When to print the names of files. Not mutually exclusive in SYSV format. */
|
||||
static int filename_per_file = 0; /* Once per file, on its own line. */
|
||||
@@ -226,6 +227,7 @@ static struct option long_options[] =
|
||||
{"defined-only", no_argument, &defined_only, 1},
|
||||
{"undefined-only", no_argument, &undefined_only, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{"with-symbol-versions", no_argument, &with_symbol_versions, 1},
|
||||
{0, no_argument, 0, 0}
|
||||
};
|
||||
|
||||
@@ -271,6 +273,7 @@ usage (FILE *stream, int status)
|
||||
-t, --radix=RADIX Use RADIX for printing symbol values\n\
|
||||
--target=BFDNAME Specify the target object format as BFDNAME\n\
|
||||
-u, --undefined-only Display only undefined symbols\n\
|
||||
--with-symbol-versions Display version strings after symbol names\n\
|
||||
-X 32_64 (ignored)\n\
|
||||
@FILE Read options from FILE\n\
|
||||
-h, --help Display this information\n\
|
||||
@@ -879,6 +882,21 @@ print_symbol (bfd * abfd,
|
||||
|
||||
format->print_symbol_info (&info, abfd);
|
||||
|
||||
if (with_symbol_versions)
|
||||
{
|
||||
const char * version_string = NULL;
|
||||
bfd_boolean hidden = FALSE;
|
||||
|
||||
if ((sym->flags & BSF_SYNTHETIC) == 0)
|
||||
version_string = bfd_get_symbol_version_string (abfd, sym, &hidden);
|
||||
|
||||
if (bfd_is_und_section (bfd_get_section (sym)))
|
||||
hidden = TRUE;
|
||||
|
||||
if (version_string && *version_string != '\0')
|
||||
printf (hidden ? "@%s" : "@@%s", version_string);
|
||||
}
|
||||
|
||||
if (line_numbers)
|
||||
{
|
||||
static asymbol **syms;
|
||||
|
||||
Reference in New Issue
Block a user