aboutsummaryrefslogtreecommitdiff
path: root/ld/ldmisc.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2002-06-26 13:22:55 +0000
committerAlan Modra <amodra@gmail.com>2002-06-26 13:22:55 +0000
commitfc28fbc2a987c714d48af78ffd43743c462f991e (patch)
treecb670d777c6730c96ff9398ed9ca864c939fa606 /ld/ldmisc.c
parent6c6783ff8c5c30ad18c3431297b7bd1ce9274dd8 (diff)
downloadfsf-binutils-gdb-fc28fbc2a987c714d48af78ffd43743c462f991e.zip
fsf-binutils-gdb-fc28fbc2a987c714d48af78ffd43743c462f991e.tar.gz
fsf-binutils-gdb-fc28fbc2a987c714d48af78ffd43743c462f991e.tar.bz2
* ldmisc.c (demangle): Restore dots stripped from sym name.
Diffstat (limited to 'ld/ldmisc.c')
-rw-r--r--ld/ldmisc.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/ld/ldmisc.c b/ld/ldmisc.c
index 42adcee..b24678e 100644
--- a/ld/ldmisc.c
+++ b/ld/ldmisc.c
@@ -78,13 +78,31 @@ demangle (string)
/* This is a hack for better error reporting on XCOFF, PowerPC64-ELF
or the MS PE format. These formats have a number of leading '.'s
- on at least some symbols, so we remove all dots. */
+ on at least some symbols, so we remove all dots to avoid
+ confusing the demangler. */
p = string;
while (*p == '.')
++p;
res = cplus_demangle (p, DMGL_ANSI | DMGL_PARAMS);
- return res ? res : xstrdup (string);
+ if (res)
+ {
+ size_t dots = p - string;
+
+ /* Now put back any stripped dots. */
+ if (dots != 0)
+ {
+ size_t len = strlen (res) + 1;
+ char *add_dots = xmalloc (len + dots);
+
+ memcpy (add_dots, string, dots);
+ memcpy (add_dots + dots, res, len);
+ free (res);
+ res = add_dots;
+ }
+ return res;
+ }
+ return xstrdup (string);
}
static void