aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-12-30 22:00:57 +1030
committerAlan Modra <amodra@gmail.com>2020-12-31 19:07:02 +1030
commitcab3f4da68672647cde72bc0c06ec08977819817 (patch)
tree868487907ff13abe6b131e712cae5e5eb3d5d146 /binutils
parent4ff509e75bf3488c302bea86b0db3dcdcad30818 (diff)
downloadgdb-cab3f4da68672647cde72bc0c06ec08977819817.zip
gdb-cab3f4da68672647cde72bc0c06ec08977819817.tar.gz
gdb-cab3f4da68672647cde72bc0c06ec08977819817.tar.bz2
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.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog7
-rw-r--r--binutils/nm.c28
2 files changed, 22 insertions, 13 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 9bbe1fe..7bd5584 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,10 @@
+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-12-29 H.J. Lu <hongjiu.lu@intel.com>
* elfedit (usage): Pass osabi to reconcat.
diff --git a/binutils/nm.c b/binutils/nm.c
index 2946bd6..e77828e 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -407,21 +407,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;
@@ -431,11 +427,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