From: Alan Modra Date: Wed, 26 Jun 2002 13:22:55 +0000 (+0000) Subject: * ldmisc.c (demangle): Restore dots stripped from sym name. X-Git-Tag: binutils-2_13-branchpoint~213 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc28fbc2a987c714d48af78ffd43743c462f991e;p=platform%2Fupstream%2Fbinutils.git * ldmisc.c (demangle): Restore dots stripped from sym name. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 5fd9bb7..593fd27 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,7 @@ +2002-06-26 Alan Modra + + * ldmisc.c (demangle): Restore dots stripped from sym name. + 2002-06-25 H.J. Lu * Makefile.am (check-DEJAGNU): Set LC_ALL=C and export it. 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