diff options
author | Alan Modra <amodra@bigpond.net.au> | 2002-06-26 13:23:45 +0000 |
---|---|---|
committer | Alan Modra <amodra@bigpond.net.au> | 2002-06-26 13:23:45 +0000 |
commit | e57862e0f7aa5688e87f77d139d08c3843d3fc56 (patch) | |
tree | b5b1d1ed73852618c9fe3dcf01672084cf177d28 /binutils/nm.c | |
parent | 5aa4202af7d5b5f1ab44bc75bb2a19ba76cf7250 (diff) | |
download | binutils-redhat-e57862e0f7aa5688e87f77d139d08c3843d3fc56.tar.gz |
* nm.c (print_symname): When demangling, strip leading dots from
symbol names to avoid confusing the demangler.
Diffstat (limited to 'binutils/nm.c')
-rw-r--r-- | binutils/nm.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/binutils/nm.c b/binutils/nm.c index 306f2c60e3..f97732e0e2 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -1086,6 +1086,7 @@ print_symname (format, name, abfd) if (do_demangle && *name) { char *res; + const char *p; /* In this mode, give a user-level view of the symbol name even if it's not mangled; strip off any leading @@ -1093,9 +1094,30 @@ print_symname (format, name, abfd) if (bfd_get_symbol_leading_char (abfd) == name[0]) name++; - res = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS); + /* This is a hack for 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 to avoid confusing the + demangler. */ + p = name; + while (*p == '.') + ++p; + + res = cplus_demangle (p, DMGL_ANSI | DMGL_PARAMS); if (res) { + size_t dots = p - name; + + /* Now put back any stripped dots. */ + if (dots != 0) + { + size_t len = strlen (res) + 1; + char *add_dots = xmalloc (len + dots); + + memcpy (add_dots, name, dots); + memcpy (add_dots + dots, res, len); + free (res); + res = add_dots; + } printf (format, res); free (res); return; |