From 73705ac309d244b61d3b372d61e867c05d8ea2a8 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 19 Apr 2007 10:45:59 +0000 Subject: [PATCH] * ldcref.c (cref_fill_array): Call bfd_demangle rather than demangle. * ldlang.c (lang_one_common): Likewise. * ldmisc.c (vfinfo): Likewise. (demangle): Delete. * ldmisc.h (demangle): Delete. * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. --- ld/ChangeLog | 10 +++++++ ld/Makefile.am | 8 +++--- ld/Makefile.in | 8 +++--- ld/ldcref.c | 4 ++- ld/ldlang.c | 3 +- ld/ldmisc.c | 76 +++++++++++++++----------------------------------- ld/ldmisc.h | 3 +- 7 files changed, 46 insertions(+), 66 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 50a474aed31..e2f75847e84 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,13 @@ +2007-04-19 Alan Modra + + * ldcref.c (cref_fill_array): Call bfd_demangle rather than demangle. + * ldlang.c (lang_one_common): Likewise. + * ldmisc.c (vfinfo): Likewise. + (demangle): Delete. + * ldmisc.h (demangle): Delete. + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + 2007-04-18 Alan Modra * ldlang.h (enum section_type): Add overlay_section. diff --git a/ld/Makefile.am b/ld/Makefile.am index b6ac5a5cfc8..80ec9eba42f 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -1960,7 +1960,7 @@ ldemul.o: ldemul.c config.h ../bfd/bfd.h $(INCDIR)/ansidecl.h \ ldexp.o: ldexp.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/fopen-same.h \ $(INCDIR)/bfdlink.h ld.h ldmain.h ldmisc.h ldexp.h \ - ldgram.h ldlang.h $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h \ + ldlex.h ldgram.h ldlang.h $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h \ $(INCDIR)/safe-ctype.h ldfile.o: ldfile.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/fopen-same.h \ @@ -1998,7 +1998,7 @@ ldwrite.o: ldwrite.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/safe-ctype.h ld.h ldexp.h ldlang.h ldwrite.h \ ldmisc.h ldgram.h ldmain.h lexsup.o: lexsup.c config.h ../bfd/bfd.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/symcat.h sysdep.h $(INCDIR)/fopen-same.h \ + $(INCDIR)/symcat.h ../bfd/bfdver.h sysdep.h $(INCDIR)/fopen-same.h \ $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h $(INCDIR)/safe-ctype.h \ $(INCDIR)/bfdlink.h ld.h ldmain.h ldmisc.h ldexp.h \ ldlang.h ldgram.h ldlex.h ldfile.h ldver.h ldemul.h \ @@ -2010,8 +2010,8 @@ mri.o: mri.c ../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \ ldcref.o: ldcref.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/fopen-same.h \ $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/objalloc.h ld.h ldmain.h ldmisc.h ldexp.h \ - ldlang.h + $(INCDIR)/demangle.h $(INCDIR)/libiberty.h $(INCDIR)/objalloc.h \ + ld.h ldmain.h ldmisc.h ldexp.h ldlang.h pe-dll.o: pe-dll.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/fopen-same.h \ $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h \ diff --git a/ld/Makefile.in b/ld/Makefile.in index 28400cc534e..1735b808e43 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -2735,7 +2735,7 @@ ldemul.o: ldemul.c config.h ../bfd/bfd.h $(INCDIR)/ansidecl.h \ ldexp.o: ldexp.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/fopen-same.h \ $(INCDIR)/bfdlink.h ld.h ldmain.h ldmisc.h ldexp.h \ - ldgram.h ldlang.h $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h \ + ldlex.h ldgram.h ldlang.h $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h \ $(INCDIR)/safe-ctype.h ldfile.o: ldfile.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/fopen-same.h \ @@ -2773,7 +2773,7 @@ ldwrite.o: ldwrite.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/safe-ctype.h ld.h ldexp.h ldlang.h ldwrite.h \ ldmisc.h ldgram.h ldmain.h lexsup.o: lexsup.c config.h ../bfd/bfd.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/symcat.h sysdep.h $(INCDIR)/fopen-same.h \ + $(INCDIR)/symcat.h ../bfd/bfdver.h sysdep.h $(INCDIR)/fopen-same.h \ $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h $(INCDIR)/safe-ctype.h \ $(INCDIR)/bfdlink.h ld.h ldmain.h ldmisc.h ldexp.h \ ldlang.h ldgram.h ldlex.h ldfile.h ldver.h ldemul.h \ @@ -2785,8 +2785,8 @@ mri.o: mri.c ../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \ ldcref.o: ldcref.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/fopen-same.h \ $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/objalloc.h ld.h ldmain.h ldmisc.h ldexp.h \ - ldlang.h + $(INCDIR)/demangle.h $(INCDIR)/libiberty.h $(INCDIR)/objalloc.h \ + ld.h ldmain.h ldmisc.h ldexp.h ldlang.h pe-dll.o: pe-dll.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/fopen-same.h \ $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h \ diff --git a/ld/ldcref.c b/ld/ldcref.c index e016451680c..3c0763b5a05 100644 --- a/ld/ldcref.c +++ b/ld/ldcref.c @@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. #include "sysdep.h" #include "bfdlink.h" #include "libiberty.h" +#include "demangle.h" #include "objalloc.h" #include "ld.h" @@ -324,7 +325,8 @@ cref_fill_array (struct cref_hash_entry *h, void *data) struct cref_hash_entry ***pph = data; ASSERT (h->demangled == NULL); - h->demangled = demangle (h->root.string); + h->demangled = bfd_demangle (output_bfd, h->root.string, + DMGL_ANSI | DMGL_PARAMS); **pph = h; diff --git a/ld/ldlang.c b/ld/ldlang.c index 297df20a301..369f6545f42 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -5267,7 +5267,8 @@ lang_one_common (struct bfd_link_hash_entry *h, void *info) header_printed = TRUE; } - name = demangle (h->root.string); + name = bfd_demangle (output_bfd, h->root.string, + DMGL_ANSI | DMGL_PARAMS); minfo ("%s", name); len = strlen (name); free (name); diff --git a/ld/ldmisc.c b/ld/ldmisc.c index 8af043aa2b2..9cf64a98585 100644 --- a/ld/ldmisc.c +++ b/ld/ldmisc.c @@ -1,6 +1,6 @@ /* ldmisc.c Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2006 + 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support. @@ -144,17 +144,24 @@ vfinfo (FILE *fp, const char *fmt, va_list arg, bfd_boolean is_warning) const char *name = va_arg (arg, const char *); if (name == NULL || *name == 0) - fprintf (fp, _("no symbol")); - else if (! demangling) - fprintf (fp, "%s", name); - else + { + fprintf (fp, _("no symbol")); + break; + } + else if (demangling) { char *demangled; - demangled = demangle (name); - fprintf (fp, "%s", demangled); - free (demangled); + demangled = bfd_demangle (output_bfd, name, + DMGL_ANSI | DMGL_PARAMS); + if (demangled != NULL) + { + fprintf (fp, "%s", demangled); + free (demangled); + break; + } } + fprintf (fp, "%s", name); } break; @@ -432,48 +439,6 @@ vfinfo (FILE *fp, const char *fmt, va_list arg, bfd_boolean is_warning) xexit (1); } -/* Wrapper around cplus_demangle. Strips leading underscores and - other such chars that would otherwise confuse the demangler. */ - -char * -demangle (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 @@ -512,11 +477,14 @@ info_assert (const char *file, unsigned int line) void minfo (const char *fmt, ...) { - va_list arg; + if (config.map_file != NULL) + { + va_list arg; - va_start (arg, fmt); - vfinfo (config.map_file, fmt, arg, FALSE); - va_end (arg); + va_start (arg, fmt); + vfinfo (config.map_file, fmt, arg, FALSE); + va_end (arg); + } } void diff --git a/ld/ldmisc.h b/ld/ldmisc.h index cf704335463..92f4e2a65ee 100644 --- a/ld/ldmisc.h +++ b/ld/ldmisc.h @@ -1,5 +1,5 @@ /* ldmisc.h - - Copyright 1991, 1992, 1993, 1994, 1996, 1997, 2001, 2003, 2004 + Copyright 1991, 1992, 1993, 1994, 1996, 1997, 2001, 2003, 2004, 2007 Free Software Foundation, Inc. This file is part of GLD, the Gnu Linker. @@ -40,6 +40,5 @@ do { info_assert(__FILE__,__LINE__); } while (0) extern void print_space (void); extern void print_nl (void); -extern char *demangle (const char *); #endif -- 2.30.2