]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR27128, nm -P portable output format regression
authorAlan Modra <amodra@gmail.com>
Sat, 27 Feb 2021 05:09:05 +0000 (15:39 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 1 Mar 2021 03:56:39 +0000 (14:26 +1030)
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.

binutils/ChangeLog
binutils/doc/binutils.texi
binutils/nm.c
ld/ChangeLog
ld/testsuite/ld-elf/pr25708.d
ld/testsuite/ld-elf/pr27128a.d
ld/testsuite/ld-elf/pr27128b.d
ld/testsuite/ld-elf/pr27128c.d
ld/testsuite/ld-elf/pr27128d.d
ld/testsuite/ld-elf/pr27128e.d

index 4289eb5e83d05b8e4160b6a37a009d1b4cad47c9..419be6410347af1a44ae75aff5c314a3c946eb36 100644 (file)
@@ -1,3 +1,16 @@
+2021-03-01  Alan Modra  <amodra@gmail.com>
+
+       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.
+
 2021-02-26  Fangrui Song  <maskray@google.com>
 
        PR 27408
index b7740dfc8a4f50b7d50d3bdb0d95ea86b38197eb..ee898331dd886a0c732c663f537ecf7af92f7409 100644 (file)
@@ -808,7 +808,8 @@ nm [@option{-A}|@option{-o}|@option{--print-file-name}] [@option{-a}|@option{--d
    [@option{--plugin} @var{name}]
    [@option{--no-recurse-limit}|@option{--recurse-limit}]]
    [@option{--size-sort}] [@option{--special-syms}]
-   [@option{--synthetic}] [@option{--target=}@var{bfdname}]
+   [@option{--synthetic}] [@option{--with-symbol-versions}]
+   [@option{--without-symbol-versions}] [@option{--target=}@var{bfdname}]
    [@var{objfile}@dots{}]
 @c man end
 @end smallexample
@@ -1169,6 +1170,16 @@ Include synthetic symbols in the output.  These are special symbols
 created by the linker for various purposes.  They are not shown by
 default since they are not part of the binary's original source code.
 
+@item --with-symbol-versions
+@item --without-symbol-versions
+Enables or disables the display of symbol version information.  The
+version string is displayed as a suffix to the symbol name, preceded
+by an @@ character.  For example @samp{foo@@VER_1}.  If the version is
+the default version to be used when resolving unversioned references
+to the symbol then it is displayed as a suffix preceded by two @@
+characters.  For example @samp{foo@@@@VER_2}.  By default, symbol
+version information is displayed.
+
 @item --target=@var{bfdname}
 @cindex object code format
 Specify an object code format other than your system's default format.
index a51d2eff75d70f6b66a953e31665e2634eb2b46a..2637756c6475694808c30d3f404832ebf69dcb47 100644 (file)
@@ -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}
 };
 \f
@@ -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;
index 6540407237c8f487105c786585d5240db86ed8be..873928608bdbb7dd2af01ceb7d3de05757cbe3e6 100644 (file)
@@ -1,3 +1,12 @@
+2021-03-01  Alan Modra  <amodra@gmail.com>
+
+       * 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.
+
 2021-02-26  Alan Modra  <amodra@gmail.com>
 
        PR 27441
index 30cae8cd516baf42719701feb8a7336bc8d0250f..60b8e31807a407df6ae6d13e46d234ccf0c80f1c 100644 (file)
@@ -1,6 +1,6 @@
 #source: pr13195.s
 #ld: -shared -version-script pr13195.t
-#nm: -D
+#nm: -D --with-symbol-versions
 #target: *-*-linux* *-*-gnu* arm*-*-uclinuxfdpiceabi
 #xfail: hppa64-*-* ![check_shared_lib_support] 
 # h8300 doesn't support -shared, and hppa64 creates .foo
index 9ce8eaa5467f54c6060802a6869257e7595c4307..645d0ccf01ccae4aff1599996afec0c48d14105f 100644 (file)
@@ -1,6 +1,6 @@
 #source: pr27128.s
 #ld: -shared -version-script pr27128.t
-#nm: -n -P
+#nm: -n -P --with-symbol-versions
 #target: [check_shared_lib_support]
 #notarget: [is_underscore_target]
 # _Zrm1XS_ doesn't have an extra underscore.
index 934f8330d761754b2fe14f6554e08ed9dd154ab0..0721117edfa5a8adeb829ef5bc695abb9e2ab7a6 100644 (file)
@@ -1,6 +1,6 @@
 #source: pr27128.s
 #ld: -shared -version-script pr27128.t
-#nm: -n -D --format=posix
+#nm: -n -D --format=posix --with-symbol-versions
 #target: [check_shared_lib_support]
 #notarget: [is_underscore_target]
 # _Zrm1XS_ doesn't have an extra underscore.
index f80c57b64cdca1f67f2bcf9d45f4ff983bf22ef2..d9cee44a718224d476360d0f73de6c03a1cf8dff 100644 (file)
@@ -1,6 +1,6 @@
 #source: pr27128.s
 #ld: -shared -version-script pr27128.t
-#nm: -n --format=sysv
+#nm: -n --format=sysv --with-symbol-versions
 #target: [check_shared_lib_support]
 #notarget: [is_underscore_target]
 # _Zrm1XS_ doesn't have an extra underscore.
index ba628d22de3ac2827df960a866bb1a2b18bbc9ec..45d19729483d4cdb08cab07759c4a1f4c6f7c837 100644 (file)
@@ -1,6 +1,6 @@
 #source: pr27128.s
 #ld: -shared -version-script pr27128.t
-#nm: -n -D --format=sysv
+#nm: -n -D --format=sysv --with-symbol-versions
 #target: [check_shared_lib_support]
 #notarget: [is_underscore_target]
 # _Zrm1XS_ doesn't have an extra underscore.
index b8b1657fe712334de343a852831d218f9c22c7af..4263a059b57621fa5032999cfb9c0859560926a0 100644 (file)
@@ -1,6 +1,6 @@
 #source: pr27128.s
 #ld: -shared -version-script pr27128.t
-#nm: -n --demangle -D --format=posix
+#nm: -n --demangle -D --format=posix --with-symbol-versions
 #target: [check_shared_lib_support]
 #notarget: [is_underscore_target]
 # _Zrm1XS_ doesn't have an extra underscore.