aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-12-30 22:00:57 +1030
committerAndreas K. Hüttel <dilfridge@gentoo.org>2021-01-23 20:26:07 +0200
commitb90561ff97786d81aa38a082100fc0bbe9079069 (patch)
tree9b3a77ec7618b93489c20e4eff253e42992a7f65
parentsparc testsuite fallout (diff)
downloadbinutils-gdb-b90561ff97786d81aa38a082100fc0bbe9079069.tar.gz
binutils-gdb-b90561ff97786d81aa38a082100fc0bbe9079069.tar.bz2
binutils-gdb-b90561ff97786d81aa38a082100fc0bbe9079069.zip
PR27128, nm -P portable output format regression
binutils/ PR 27128 * nm.c (print_symname): Append version string to symbol name before printing the lot under control of "form". Append version to demangled names too. ld/ PR 27128 * testsuite/ld-elf/pr27128.s: New file. * testsuite/ld-elf/pr27128.t: Likewise. * 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. (cherry picked from commit cab3f4da68672647cde72bc0c06ec08977819817) (cherry picked from commit 5ca7ac981b734591b1ca0acc36c2b2081e64d06c)
-rw-r--r--binutils/ChangeLog6
-rw-r--r--binutils/nm.c28
-rw-r--r--ld/ChangeLog11
-rw-r--r--ld/testsuite/ld-elf/pr27128.s13
-rw-r--r--ld/testsuite/ld-elf/pr27128.t6
-rw-r--r--ld/testsuite/ld-elf/pr27128a.d16
-rw-r--r--ld/testsuite/ld-elf/pr27128b.d16
-rw-r--r--ld/testsuite/ld-elf/pr27128c.d16
-rw-r--r--ld/testsuite/ld-elf/pr27128d.d16
-rw-r--r--ld/testsuite/ld-elf/pr27128e.d16
10 files changed, 131 insertions, 13 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index c54b39f395..4b6cd9f755 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,6 +1,12 @@
2021-01-01 Alan Modra <amodra@gmail.com>
Apply from master
+ 2020-12-31 Alan Modra <amodra@gmail.com>
+ PR 27128
+ * nm.c (print_symname): Append version string to symbol name
+ before printing the lot under control of "form". Append version
+ to demangled names too.
+
2020-08-22 H.J. Lu <hongjiu.lu@intel.com>
PR ld/26382
* nm.c (print_symname): Display only one '@' for undefined
diff --git a/binutils/nm.c b/binutils/nm.c
index 3501f48d29..a5144faba6 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -397,21 +397,17 @@ static void
print_symname (const char *form, struct extended_symbol_info *info,
const char *name, bfd *abfd)
{
+ char *alloc = NULL;
+
if (name == NULL)
name = info->sinfo->name;
if (do_demangle && *name)
{
- char *res = bfd_demangle (abfd, name, demangle_flags);
-
- if (res != NULL)
- {
- printf (form, res);
- free (res);
- return;
- }
+ alloc = bfd_demangle (abfd, name, demangle_flags);
+ if (alloc != NULL)
+ name = alloc;
}
- printf (form, name);
if (info != NULL && info->elfinfo)
{
const char *version_string;
@@ -421,11 +417,17 @@ print_symname (const char *form, struct extended_symbol_info *info,
= bfd_get_symbol_version_string (abfd, &info->elfinfo->symbol,
FALSE, &hidden);
if (version_string && version_string[0])
- printf ("%s%s",
- (hidden || bfd_is_und_section (info->elfinfo->symbol.section)
- ? "@" : "@@"),
- version_string);
+ {
+ const char *at = "@@";
+ if (hidden || bfd_is_und_section (info->elfinfo->symbol.section))
+ at = "@";
+ alloc = reconcat (alloc, name, at, version_string, NULL);
+ if (alloc != NULL)
+ name = alloc;
+ }
}
+ printf (form, name);
+ free (alloc);
}
static void
diff --git a/ld/ChangeLog b/ld/ChangeLog
index af9d2c9eeb..2f2c1353b9 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,6 +1,17 @@
2021-01-01 Alan Modra <amodra@gmail.com>
Apply from master
+ 2020-12-31 H.J. Lu <hongjiu.lu@intel.com>
+ Alan Modra <amodra@gmail.com>
+ PR 27128
+ * testsuite/ld-elf/pr27128.s: New file.
+ * testsuite/ld-elf/pr27128.t: Likewise.
+ * 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.
+
2020-08-24 Alan Modra <amodra@gmail.com>
* testsuite/ld-sparc/tlssunbin32.rd: Update for new readelf output.
* testsuite/ld-sparc/tlssunbin64.rd: Likewise.
diff --git a/ld/testsuite/ld-elf/pr27128.s b/ld/testsuite/ld-elf/pr27128.s
new file mode 100644
index 0000000000..7af5be183b
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr27128.s
@@ -0,0 +1,13 @@
+ .text
+ .globl foo
+ .type foo,%function
+foo:
+ .space 16
+ .size foo, .-foo
+ .symver foo,foo@@VERS_2.0,remove
+ .globl _Zrm1XS_
+ .type _Zrm1XS_,%function
+_Zrm1XS_:
+ .space 16
+ .size _Zrm1XS_, .-_Zrm1XS_
+ .symver _Zrm1XS_,_Zrm1XS_@@VERS_2.0,remove
diff --git a/ld/testsuite/ld-elf/pr27128.t b/ld/testsuite/ld-elf/pr27128.t
new file mode 100644
index 0000000000..27669a505b
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr27128.t
@@ -0,0 +1,6 @@
+VERS_2.0 {
+global:
+ foo; _Zrm1XS_;
+local:
+ *;
+};
diff --git a/ld/testsuite/ld-elf/pr27128a.d b/ld/testsuite/ld-elf/pr27128a.d
new file mode 100644
index 0000000000..9ce8eaa546
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr27128a.d
@@ -0,0 +1,16 @@
+#source: pr27128.s
+#ld: -shared -version-script pr27128.t
+#nm: -n -P
+#target: [check_shared_lib_support]
+#notarget: [is_underscore_target]
+# _Zrm1XS_ doesn't have an extra underscore.
+#xfail: hppa64-*-* tic6x-*-*
+# hppa64 uses dot-symbols, tic6x DYN lacks dynamic sections for this testcase
+
+#...
+VERS_2\.0 A 0+
+#...
+foo@@VERS_2\.0 T [0-9a-f]+ 10
+#...
+_Zrm1XS_@@VERS_2\.0 T [0-9a-f]+ 10
+#pass
diff --git a/ld/testsuite/ld-elf/pr27128b.d b/ld/testsuite/ld-elf/pr27128b.d
new file mode 100644
index 0000000000..934f8330d7
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr27128b.d
@@ -0,0 +1,16 @@
+#source: pr27128.s
+#ld: -shared -version-script pr27128.t
+#nm: -n -D --format=posix
+#target: [check_shared_lib_support]
+#notarget: [is_underscore_target]
+# _Zrm1XS_ doesn't have an extra underscore.
+#xfail: hppa64-*-* tic6x-*-*
+# hppa64 uses dot-symbols, tic6x DYN lacks dynamic sections for this testcase
+
+#...
+VERS_2\.0 A 0+
+#...
+foo@@VERS_2\.0 T [0-9a-f]+ 10
+#...
+_Zrm1XS_@@VERS_2\.0 T [0-9a-f]+ 10
+#pass
diff --git a/ld/testsuite/ld-elf/pr27128c.d b/ld/testsuite/ld-elf/pr27128c.d
new file mode 100644
index 0000000000..f80c57b64c
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr27128c.d
@@ -0,0 +1,16 @@
+#source: pr27128.s
+#ld: -shared -version-script pr27128.t
+#nm: -n --format=sysv
+#target: [check_shared_lib_support]
+#notarget: [is_underscore_target]
+# _Zrm1XS_ doesn't have an extra underscore.
+#xfail: hppa64-*-* tic6x-*-*
+# hppa64 uses dot-symbols, tic6x DYN lacks dynamic sections for this testcase
+
+#...
+VERS_2\.0 +\|0+\| +A +\| +OBJECT\| +\| +\|\*ABS\*
+#...
+foo@@VERS_2\.0 +\|[0-9a-f]+\| +T +\| +FUNC\|0+10\| +\|\.text
+#...
+_Zrm1XS_@@VERS_2\.0 +\|[0-9a-f]+\| +T +\| +FUNC\|0+10\| +\|\.text
+#pass
diff --git a/ld/testsuite/ld-elf/pr27128d.d b/ld/testsuite/ld-elf/pr27128d.d
new file mode 100644
index 0000000000..ba628d22de
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr27128d.d
@@ -0,0 +1,16 @@
+#source: pr27128.s
+#ld: -shared -version-script pr27128.t
+#nm: -n -D --format=sysv
+#target: [check_shared_lib_support]
+#notarget: [is_underscore_target]
+# _Zrm1XS_ doesn't have an extra underscore.
+#xfail: hppa64-*-* tic6x-*-*
+# hppa64 uses dot-symbols, tic6x DYN lacks dynamic sections for this testcase
+
+#...
+VERS_2\.0 +\|0+\| +A +\| +OBJECT\| +\| +\|\*ABS\*
+#...
+foo@@VERS_2\.0 +\|[0-9a-f]+\| +T +\| +FUNC\|0+10\| +\|\.text
+#...
+_Zrm1XS_@@VERS_2\.0 +\|[0-9a-f]+\| +T +\| +FUNC\|0+10\| +\|\.text
+#pass
diff --git a/ld/testsuite/ld-elf/pr27128e.d b/ld/testsuite/ld-elf/pr27128e.d
new file mode 100644
index 0000000000..b8b1657fe7
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr27128e.d
@@ -0,0 +1,16 @@
+#source: pr27128.s
+#ld: -shared -version-script pr27128.t
+#nm: -n --demangle -D --format=posix
+#target: [check_shared_lib_support]
+#notarget: [is_underscore_target]
+# _Zrm1XS_ doesn't have an extra underscore.
+#xfail: hppa64-*-* tic6x-*-*
+# hppa64 uses dot-symbols, tic6x DYN lacks dynamic sections for this testcase
+
+#...
+VERS_2\.0 A 0+
+#...
+foo@@VERS_2\.0 T [0-9a-f]+ 10
+#...
+operator%\(X, X\)@@VERS_2\.0 T [0-9a-f]+ 10
+#pass