aboutsummaryrefslogtreecommitdiff
path: root/binutils/nm.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-02-27 15:39:05 +1030
committerAlan Modra <amodra@gmail.com>2021-03-01 14:26:39 +1030
commit6a1224ec762f7dd59d7abd2e5dc3be26bb157cd1 (patch)
tree1e35d6d43b5efe25d4b7fc5e5ee818eb38e0742b /binutils/nm.c
parentcf850febf6d2e3945670386c707a86363919e9ee (diff)
downloadfsf-binutils-gdb-6a1224ec762f7dd59d7abd2e5dc3be26bb157cd1.zip
fsf-binutils-gdb-6a1224ec762f7dd59d7abd2e5dc3be26bb157cd1.tar.gz
fsf-binutils-gdb-6a1224ec762f7dd59d7abd2e5dc3be26bb157cd1.tar.bz2
PR27128, nm -P portable output format regression
Add nm --without-symbol-versions. binutils/ PR 27128 * doc/binutils.texi: Add nm --with-symbol-versions and --without-symbol-versions documentation. * nm.c (with_symbol_versions): New variable. (enum long_option_values): Delete OPTION_WITH_SYMBOL_VERSIONS. (long_options): Make --with-symbol-versions entry twiddle the flag. Add --without-symbol-versions. (print_symname): Strip version when !with_symbol_versions. Add dynamic version info under control of with_symbol_versions. (main): Remove OPTION_WITH_SYMBOL_VERSIONS case. ld/ * testsuite/ld-elf/pr25708.d: Add --with-symbol-versions to nm. * testsuite/ld-elf/pr27128a.d: Likewise. * testsuite/ld-elf/pr27128b.d: Likewise. * testsuite/ld-elf/pr27128c.d: Likewise. * testsuite/ld-elf/pr27128d.d: Likewise. * testsuite/ld-elf/pr27128e.d: Likewise.
Diffstat (limited to 'binutils/nm.c')
-rw-r--r--binutils/nm.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/binutils/nm.c b/binutils/nm.c
index a51d2ef..2637756 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 with_symbol_versions = -1; /* Output symbol version information. */
static int quiet = 0; /* Suppress "no symbols" diagnostic. */
/* The characters to use for global and local ifunc symbols. */
@@ -201,7 +202,6 @@ enum long_option_values
OPTION_RECURSE_LIMIT,
OPTION_NO_RECURSE_LIMIT,
OPTION_IFUNC_CHARS,
- OPTION_WITH_SYMBOL_VERSIONS,
OPTION_QUIET
};
@@ -238,8 +238,8 @@ 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, NULL,
- OPTION_WITH_SYMBOL_VERSIONS},
+ {"with-symbol-versions", no_argument, &with_symbol_versions, 1},
+ {"without-symbol-versions", no_argument, &with_symbol_versions, 0},
{0, no_argument, 0, 0}
};
@@ -412,9 +412,17 @@ print_symname (const char *form, struct extended_symbol_info *info,
const char *name, bfd *abfd)
{
char *alloc = NULL;
+ char *atver = NULL;
if (name == NULL)
name = info->sinfo->name;
+ if (!with_symbol_versions
+ && bfd_get_flavour (abfd) == bfd_target_elf_flavour)
+ {
+ atver = strchr (name, '@');
+ if (atver)
+ *atver = 0;
+ }
if (do_demangle && *name)
{
alloc = bfd_demangle (abfd, name, demangle_flags);
@@ -422,7 +430,7 @@ print_symname (const char *form, struct extended_symbol_info *info,
name = alloc;
}
- if (info != NULL && info->elfinfo)
+ if (info != NULL && info->elfinfo && with_symbol_versions)
{
const char *version_string;
bfd_boolean hidden;
@@ -441,6 +449,8 @@ print_symname (const char *form, struct extended_symbol_info *info,
}
}
printf (form, name);
+ if (atver)
+ *atver = '@';
free (alloc);
}
@@ -1780,9 +1790,6 @@ main (int argc, char **argv)
case OPTION_NO_RECURSE_LIMIT:
demangle_flags |= DMGL_NO_RECURSE_LIMIT;
break;
- case OPTION_WITH_SYMBOL_VERSIONS:
- /* Ignored for backward compatibility. */
- break;
case OPTION_QUIET:
quiet = 1;
break;