* powerpc64 and "nm -C"
@ 2002-06-26 6:21 Alan Modra
2002-06-26 10:07 ` Elias Athanasopoulos
0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2002-06-26 6:21 UTC (permalink / raw)
To: binutils; +Cc: Olaf Hering
The demangler currently doesn't work very well on powerpc64 due to
those pesky leading `.'s on function entry point symbols. I also
think it useful to be able to distinguish function descriptor syms
(without a dot) from function code syms (with dot) after demangling,
hence the ldmisc.c change.
ld/ChangeLog
* ldmisc.c (demangle): Restore dots stripped from sym name.
binutils/ChangeLog
* nm.c (print_symname): When demangling, strip leading dots from
symbol names to avoid confusing the demangler.
Index: ld/ldmisc.c
===================================================================
RCS file: /cvs/src/src/ld/ldmisc.c,v
retrieving revision 1.9
diff -u -p -r1.9 ldmisc.c
--- ld/ldmisc.c 25 Jan 2002 12:22:42 -0000 1.9
+++ ld/ldmisc.c 26 Jun 2002 13:10:26 -0000
@@ -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
Index: binutils/nm.c
===================================================================
RCS file: /cvs/src/src/binutils/nm.c,v
retrieving revision 1.27
diff -u -p -r1.27 nm.c
--- binutils/nm.c 21 Jun 2002 02:34:38 -0000 1.27
+++ binutils/nm.c 26 Jun 2002 13:10:27 -0000
@@ -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;
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: powerpc64 and "nm -C"
2002-06-26 6:21 powerpc64 and "nm -C" Alan Modra
@ 2002-06-26 10:07 ` Elias Athanasopoulos
2002-06-26 22:10 ` Alan Modra
0 siblings, 1 reply; 5+ messages in thread
From: Elias Athanasopoulos @ 2002-06-26 10:07 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils, Olaf Hering
Hi Alan,
On Wed, Jun 26, 2002 at 10:50:58PM +0930, Alan Modra wrote:
> The demangler currently doesn't work very well on powerpc64 due to
> those pesky leading `.'s on function entry point symbols. I also
> think it useful to be able to distinguish function descriptor syms
> (without a dot) from function code syms (with dot) after demangling,
> hence the ldmisc.c change.
Just a thought: wouldn't be better to embed this functionality in
the demangler, since it [the demangler] is not used only by nm?
I have attached a patch which modifies objdump, just like you did in
nm. I can't test it, since the issue concerns powerpc64. I also don't
provide a ChangeLog entry since it is really your code. :-)
Elias
--- objdump.c.orig Wed Jun 26 20:09:48 2002
+++ objdump.c Wed Jun 26 20:19:05 2002
@@ -631,6 +631,7 @@
char *alloc;
const char *name;
const char *print;
+ const char *p;
alloc = NULL;
name = bfd_asymbol_name (sym);
@@ -642,12 +643,36 @@
if (bfd_get_symbol_leading_char (abfd) == name[0])
++name;
- alloc = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS);
- if (alloc == NULL)
- print = name;
- else
+ /* 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;
+
+ alloc = cplus_demangle (p, DMGL_ANSI | DMGL_PARAMS);
+ if (alloc)
+ {
+ size_t dots = p - name;
+
+ /* Now put back any stripped dots. */
+ if (dots != 0)
+ {
+ size_t len = strlen (alloc) + 1;
+ char *add_dots = xmalloc (len + dots);
+
+ memcpy (add_dots, name, dots);
+ memcpy (add_dots + dots, alloc, len);
+ free (alloc);
+ alloc = add_dots;
+ }
+
print = alloc;
}
+ else
+ print = name;
+ }
if (info != NULL)
(*info->fprintf_func) (info->stream, "%s", print);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: powerpc64 and "nm -C"
2002-06-26 10:07 ` Elias Athanasopoulos
@ 2002-06-26 22:10 ` Alan Modra
2002-07-01 21:19 ` Alan Modra
0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2002-06-26 22:10 UTC (permalink / raw)
To: Elias Athanasopoulos; +Cc: binutils
On Wed, Jun 26, 2002 at 08:22:53PM +0300, Elias Athanasopoulos wrote:
> Just a thought: wouldn't be better to embed this functionality in
> the demangler, since it [the demangler] is not used only by nm?
Yes, you're right. Perhaps we should use a bfd_demangle function.
Thanks for pointing this out.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: powerpc64 and "nm -C"
2002-06-26 22:10 ` Alan Modra
@ 2002-07-01 21:19 ` Alan Modra
2002-07-02 0:17 ` Elias Athanasopoulos
0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2002-07-01 21:19 UTC (permalink / raw)
To: binutils
On Thu, Jun 27, 2002 at 02:39:56PM +0930, Alan Modra wrote:
> On Wed, Jun 26, 2002 at 08:22:53PM +0300, Elias Athanasopoulos wrote:
> > Just a thought: wouldn't be better to embed this functionality in
> > the demangler, since it [the demangler] is not used only by nm?
>
> Yes, you're right. Perhaps we should use a bfd_demangle function.
Then again, perhaps not. Things that go in bfd ought not abort when
running out of memory.
binutils/ChangeLog
* budemang.c: New file, "demangle" function.
* budemang.h: New file.
* addr2line.c (translate_addresses): Use "demangle".
* nm.c (print_symname): Likewise.
* objdump.c (objdump_print_symname): Likewise.
(dump_symbols): Likewise. Also, don't use bfd_asymbol_name macro
here since that obfuscates.
* rdcoff.c: Don't #include demangle.h.
* Makefile.am (CFILES): Add budemang.c, emul_aix.c,
emul_vanilla.c. Remove emul_$(EMULATION).c. Sort.
(HFILES): Add budemang.h. Sort.
(nm_new_SOURCES, objdump_SOURCES, addr2line_SOURCES): Add budemang.c.
Run "make dep-am".
* Makefile.in: Regenerate.
* po/POTFILES.in: Regenerate.
ld/ChangeLog
* ldmisc.c (demangle): Move so that it doesn't intrude between
vfinfo comment and body. Add comment.
Index: binutils/Makefile.am
===================================================================
RCS file: /cvs/src/src/binutils/Makefile.am,v
retrieving revision 1.35
diff -u -p -r1.35 Makefile.am
--- binutils/Makefile.am 26 Jun 2002 01:12:28 -0000 1.35
+++ binutils/Makefile.am 2 Jul 2002 03:48:52 -0000
@@ -78,18 +78,24 @@ INCLUDES = -D_GNU_SOURCE \
-DLOCALEDIR="\"$(prefix)/share/locale\"" \
-Dbin_dummy_emulation=$(EMULATION_VECTOR)
-HFILES = arsup.h bucomm.h budbg.h coffgrok.h debug.h nlmconv.h dlltool.h \
- windres.h winduni.h binemul.h
+HFILES = \
+ arsup.h binemul.h bucomm.h budbg.h budemang.h \
+ coffgrok.h debug.h dlltool.h nlmconv.h \
+ windres.h winduni.h
GENERATED_HFILES = arparse.h sysroff.h sysinfo.h defparse.h rcparse.h
-CFILES = addr2line.c ar.c arsup.c bucomm.c coffdump.c coffgrok.c debug.c \
- dlltool.c filemode.c ieee.c is-ranlib.c is-strip.c maybe-ranlib.c \
- maybe-strip.c nlmconv.c nm.c not-ranlib.c not-strip.c \
- objcopy.c objdump.c prdbg.c rdcoff.c rddbg.c size.c srconv.c \
- stabs.c strings.c sysdump.c version.c wrstabs.c \
- windres.c resrc.c rescoff.c resbin.c winduni.c readelf.c \
- resres.c dllwrap.c rename.c binemul.c emul_$(EMULATION).c
+CFILES = \
+ addr2line.c ar.c arsup.c binemul.c bucomm.c budemang.c \
+ coffdump.c coffgrok.c debug.c dlltool.c dllwrap.c \
+ emul_aix.c emul_vanilla.c filemode.c \
+ ieee.c is-ranlib.c is-strip.c maybe-ranlib.c maybe-strip.c \
+ nlmconv.c nm.c not-ranlib.c not-strip.c \
+ objcopy.c objdump.c prdbg.c \
+ rdcoff.c rddbg.c readelf.c rename.c \
+ resbin.c rescoff.c resrc.c resres.c \
+ size.c srconv.c stabs.c strings.c sysdump.c version.c \
+ windres.c winduni.c wrstabs.c
GENERATED_CFILES = \
underscore.c arparse.c arlex.c sysroff.c sysinfo.c syslex.c \
@@ -167,9 +172,9 @@ readelf_LDADD = $(INTLLIBS) $(LIBIBERT
strip_new_SOURCES = objcopy.c is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
-nm_new_SOURCES = nm.c $(BULIBS)
+nm_new_SOURCES = nm.c budemang.c $(BULIBS)
-objdump_SOURCES = objdump.c prdbg.c $(DEBUG_SRCS) $(BULIBS)
+objdump_SOURCES = objdump.c budemang.c prdbg.c $(DEBUG_SRCS) $(BULIBS)
objdump_LDADD = $(OPCODES) $(BFDLIB) $(LIBIBERTY) $(INTLLIBS)
objdump.o:objdump.c
@@ -197,7 +202,7 @@ ranlib_SOURCES = ar.c is-ranlib.c arpars
binemul.c emul_$(EMULATION).c $(BULIBS)
ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(INTLLIBS)
-addr2line_SOURCES = addr2line.c $(BULIBS)
+addr2line_SOURCES = addr2line.c budemang.c $(BULIBS)
# The following is commented out for the conversion to automake.
# This rule creates a single binary that switches between ar and ranlib
[snip dependency changes]
Index: binutils/budemang.c
===================================================================
RCS file: binutils/budemang.c
diff -N binutils/budemang.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ binutils/budemang.c 2 Jul 2002 03:54:46 -0000
@@ -0,0 +1,69 @@
+/* demangle.c -- A wrapper calling libiberty cplus_demangle
+ Copyright 2002 Free Software Foundation, Inc.
+
+ This file is part of GNU Binutils.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#include <stdlib.h>
+#include "bfd.h"
+#include "libiberty.h"
+#include "demangle.h"
+#include "budemang.h"
+
+/* Wrapper around cplus_demangle. Strips leading underscores and
+ other such chars that would otherwise confuse the demangler. */
+
+char *
+demangle (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ char *res;
+ const char *p;
+
+ if (abfd != NULL && bfd_get_symbol_leading_char (abfd) == 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);
+}
Index: binutils/budemang.h
===================================================================
RCS file: binutils/budemang.h
diff -N binutils/budemang.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ binutils/budemang.h 2 Jul 2002 03:54:46 -0000
@@ -0,0 +1,25 @@
+/* demangle.h -- A wrapper calling libiberty cplus_demangle
+ Copyright 2002 Free Software Foundation, Inc.
+
+ This file is part of GNU Binutils.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+#ifndef BUDEMANG_H
+#define BUDEMANG_H
+
+char *demangle PARAMS ((bfd *, const char *));
+
+#endif
Index: binutils/addr2line.c
===================================================================
RCS file: /cvs/src/src/binutils/addr2line.c,v
retrieving revision 1.14
diff -u -p -r1.14 addr2line.c
--- binutils/addr2line.c 19 May 2002 16:17:54 -0000 1.14
+++ binutils/addr2line.c 2 Jul 2002 03:48:54 -0000
@@ -35,6 +35,7 @@
#include "libiberty.h"
#include "demangle.h"
#include "bucomm.h"
+#include "budemang.h"
static boolean with_functions; /* -f, show function names. */
static boolean do_demangle; /* -C, demangle names. */
@@ -191,23 +192,22 @@ translate_addresses (abfd)
{
if (with_functions)
{
- if (functionname == NULL || *functionname == '\0')
- printf ("??\n");
- else if (! do_demangle)
- printf ("%s\n", functionname);
- else
- {
- char *res;
+ const char *name;
+ char *alloc = NULL;
- res = cplus_demangle (functionname, DMGL_ANSI | DMGL_PARAMS);
- if (res == NULL)
- printf ("%s\n", functionname);
- else
- {
- printf ("%s\n", res);
- free (res);
- }
+ name = functionname;
+ if (name == NULL || *name == '\0')
+ name = "??";
+ else if (do_demangle)
+ {
+ alloc = demangle (abfd, name);
+ name = alloc;
}
+
+ printf ("%s\n", name);
+
+ if (alloc != NULL)
+ free (alloc);
}
if (base_names && filename != NULL)
Index: binutils/nm.c
===================================================================
RCS file: /cvs/src/src/binutils/nm.c,v
retrieving revision 1.28
diff -u -p -r1.28 nm.c
--- binutils/nm.c 26 Jun 2002 13:23:45 -0000 1.28
+++ binutils/nm.c 2 Jul 2002 03:48:55 -0000
@@ -23,6 +23,7 @@
#include "bfd.h"
#include "progress.h"
#include "bucomm.h"
+#include "budemang.h"
#include "getopt.h"
#include "aout/stab_gnu.h"
#include "aout/ranlib.h"
@@ -1085,43 +1086,11 @@ print_symname (format, name, abfd)
{
if (do_demangle && *name)
{
- char *res;
- const char *p;
+ char *res = demangle (abfd, name);
- /* In this mode, give a user-level view of the symbol name
- even if it's not mangled; strip off any leading
- underscore. */
- if (bfd_get_symbol_leading_char (abfd) == name[0])
- name++;
-
- /* 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;
- }
+ printf (format, res);
+ free (res);
+ return;
}
printf (format, name);
Index: binutils/objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.53
diff -u -p -r1.53 objdump.c
--- binutils/objdump.c 8 Jun 2002 07:38:30 -0000 1.53
+++ binutils/objdump.c 2 Jul 2002 03:48:57 -0000
@@ -22,6 +22,7 @@ Foundation, 59 Temple Place - Suite 330,
#include "bfd.h"
#include "progress.h"
#include "bucomm.h"
+#include "budemang.h"
#include "getopt.h"
#include "safe-ctype.h"
#include "dis-asm.h"
@@ -630,29 +631,20 @@ objdump_print_symname (abfd, info, sym)
{
char *alloc;
const char *name;
- const char *print;
alloc = NULL;
name = bfd_asymbol_name (sym);
- if (! do_demangle || name[0] == '\0')
- print = name;
- else
+ if (do_demangle && name[0] != '\0')
{
/* Demangle the name. */
- if (bfd_get_symbol_leading_char (abfd) == name[0])
- ++name;
-
- alloc = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS);
- if (alloc == NULL)
- print = name;
- else
- print = alloc;
+ alloc = demangle (abfd, name);
+ name = alloc;
}
if (info != NULL)
- (*info->fprintf_func) (info->stream, "%s", print);
+ (*info->fprintf_func) (info->stream, "%s", name);
else
- printf ("%s", print);
+ printf ("%s", name);
if (alloc != NULL)
free (alloc);
@@ -2316,24 +2308,16 @@ dump_symbols (abfd, dynamic)
const char *name;
char *alloc;
- name = bfd_asymbol_name (*current);
+ name = (*current)->name;
alloc = NULL;
if (do_demangle && name != NULL && *name != '\0')
{
- const char *n;
-
/* If we want to demangle the name, we demangle it
here, and temporarily clobber it while calling
bfd_print_symbol. FIXME: This is a gross hack. */
- n = name;
- if (bfd_get_symbol_leading_char (cur_bfd) == *n)
- ++n;
- alloc = cplus_demangle (n, DMGL_ANSI | DMGL_PARAMS);
- if (alloc != NULL)
- (*current)->name = alloc;
- else
- (*current)->name = n;
+ alloc = demangle (cur_bfd, name);
+ (*current)->name = alloc;
}
bfd_print_symbol (cur_bfd, stdout, *current,
Index: binutils/rdcoff.c
===================================================================
RCS file: /cvs/src/src/binutils/rdcoff.c,v
retrieving revision 1.7
diff -u -p -r1.7 rdcoff.c
--- binutils/rdcoff.c 23 May 2002 04:11:56 -0000 1.7
+++ binutils/rdcoff.c 2 Jul 2002 03:48:59 -0000
@@ -25,8 +25,7 @@
#include "coff/internal.h"
#include "bucomm.h"
#include "libiberty.h"
-#include "demangle.h"
#include "debug.h"
#include "budbg.h"
Index: ld/ldmisc.c
===================================================================
RCS file: /cvs/src/src/ld/ldmisc.c,v
retrieving revision 1.10
diff -u -p -r1.10 ldmisc.c
--- ld/ldmisc.c 26 Jun 2002 13:22:55 -0000 1.10
+++ ld/ldmisc.c 2 Jul 2002 03:49:08 -0000
@@ -65,46 +65,6 @@ static void vfinfo PARAMS ((FILE *, cons
%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;
@@ -423,6 +383,49 @@ vfinfo (fp, fmt, arg)
if (fatal == true)
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. */
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: powerpc64 and "nm -C"
2002-07-01 21:19 ` Alan Modra
@ 2002-07-02 0:17 ` Elias Athanasopoulos
0 siblings, 0 replies; 5+ messages in thread
From: Elias Athanasopoulos @ 2002-07-02 0:17 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
Hi Alan,
On Tue, Jul 02, 2002 at 01:49:51PM +0930, Alan Modra wrote:
> On Thu, Jun 27, 2002 at 02:39:56PM +0930, Alan Modra wrote:
> > On Wed, Jun 26, 2002 at 08:22:53PM +0300, Elias Athanasopoulos wrote:
> > > Just a thought: wouldn't be better to embed this functionality in
> > > the demangler, since it [the demangler] is not used only by nm?
> >
> > Yes, you're right. Perhaps we should use a bfd_demangle function.
>
> Then again, perhaps not. Things that go in bfd ought not abort when
> running out of memory.
:-) Actually, *this* is what I have at first in my mind. Patching
libiberty or creating a wrapper. Nice work.
Elias
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-07-02 7:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-26 6:21 powerpc64 and "nm -C" Alan Modra
2002-06-26 10:07 ` Elias Athanasopoulos
2002-06-26 22:10 ` Alan Modra
2002-07-01 21:19 ` Alan Modra
2002-07-02 0:17 ` Elias Athanasopoulos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).