diff options
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 5 | ||||
-rw-r--r-- | ld/ldmisc.c | 83 |
2 files changed, 48 insertions, 40 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 0b91fb9..ef7323f 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2002-07-02 Alan Modra <amodra@bigpond.net.au> + + * ldmisc.c (demangle): Move so that it doesn't intrude between + vfinfo comment and body. Add comment. + 2002-07-01 John David Anglin <dave@hiauly1.hia.nrc.ca> * emulparams/vax.sh (OUTPUT_FORMAT): Use a.out-vax-bsd format. diff --git a/ld/ldmisc.c b/ld/ldmisc.c index b24678e..2869ba9 100644 --- a/ld/ldmisc.c +++ b/ld/ldmisc.c @@ -65,46 +65,6 @@ static void vfinfo PARAMS ((FILE *, const char *, va_list)); %u integer, like printf */ -char * -demangle (string) - const char *string; -{ - char *res; - const char *p; - - if (output_bfd != NULL - && bfd_get_symbol_leading_char (output_bfd) == string[0]) - ++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 to avoid - confusing the demangler. */ - p = string; - while (*p == '.') - ++p; - - res = cplus_demangle (p, DMGL_ANSI | DMGL_PARAMS); - 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 vfinfo (fp, fmt, arg) FILE *fp; @@ -425,6 +385,49 @@ vfinfo (fp, fmt, arg) xexit (1); } +/* Wrapper around cplus_demangle. Strips leading underscores and + other such chars that would otherwise confuse the demangler. */ + +char * +demangle (name) + const char *name; +{ + char *res; + const char *p; + + if (output_bfd != NULL + && bfd_get_symbol_leading_char (output_bfd) == name[0]) + ++name; + + /* 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 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; + } + return res; + } + return xstrdup (name); +} + /* Format info message and print on stdout. */ /* (You would think this should be called just "info", but then you |