diff options
author | Alan Modra <amodra@bigpond.net.au> | 2008-07-07 11:48:27 +0000 |
---|---|---|
committer | Alan Modra <amodra@bigpond.net.au> | 2008-07-07 11:48:27 +0000 |
commit | b4826cb488ebffa25c5b17a47cf57ea80075e138 (patch) | |
tree | 9724626ba875ad3407e4a97d964afcddceca7562 /bfd/bfd.c | |
parent | 68b9d1eab54f03a351e66c8f8c43cb7d174dd483 (diff) | |
download | gdb-b4826cb488ebffa25c5b17a47cf57ea80075e138.tar.gz |
* bfd.c (bfd_demangle): Always trim off bfd_get_symbol_leading_char.
Diffstat (limited to 'bfd/bfd.c')
-rw-r--r-- | bfd/bfd.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/bfd/bfd.c b/bfd/bfd.c index 7e6e872feb5..ed89e664cc7 100644 --- a/bfd/bfd.c +++ b/bfd/bfd.c @@ -1829,10 +1829,12 @@ bfd_demangle (bfd *abfd, const char *name, int options) char *res, *alloc; const char *pre, *suf; size_t pre_len; + bfd_boolean skip_lead; - if (abfd != NULL - && *name != '\0' - && bfd_get_symbol_leading_char (abfd) == *name) + skip_lead = (abfd != NULL + && *name != '\0' + && bfd_get_symbol_leading_char (abfd) == *name); + if (skip_lead) ++name; /* This is a hack for better error reporting on XCOFF, PowerPC64-ELF @@ -1863,7 +1865,18 @@ bfd_demangle (bfd *abfd, const char *name, int options) free (alloc); if (res == NULL) - return NULL; + { + if (skip_lead) + { + size_t len = strlen (pre) + 1; + alloc = bfd_malloc (len); + if (alloc == NULL) + return NULL; + memcpy (alloc, pre, len); + return alloc; + } + return NULL; + } /* Put back any prefix or suffix. */ if (pre_len != 0 || suf != NULL) |