* ldmisc.c (demangle): Move so that it doesn't intrude between

vfinfo comment and body.  Add comment.
This commit is contained in:
Alan Modra 2002-07-02 04:21:57 +00:00
parent a6637ec0ed
commit b7b482a3f5
2 changed files with 48 additions and 40 deletions

View file

@ -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.

View file

@ -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