aboutsummaryrefslogtreecommitdiff
path: root/binutils/nm.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2016-11-11 11:49:45 +0000
committerNick Clifton <nickc@redhat.com>2016-11-11 11:49:45 +0000
commitdf2c87b5803750d21f03b7d36f8d1abace3e1e14 (patch)
treef0518bd37e6acf61c8bb6a3d29c209e94664dcbe /binutils/nm.c
parent74f5402d08b857d60499b27851c204954ce6c42c (diff)
downloadgdb-df2c87b5803750d21f03b7d36f8d1abace3e1e14.zip
gdb-df2c87b5803750d21f03b7d36f8d1abace3e1e14.tar.gz
gdb-df2c87b5803750d21f03b7d36f8d1abace3e1e14.tar.bz2
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.
Diffstat (limited to 'binutils/nm.c')
-rw-r--r--binutils/nm.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/binutils/nm.c b/binutils/nm.c
index 6d88748..d537441 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -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;