From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16648 invoked by alias); 26 Jun 2002 13:21:06 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 16629 invoked from network); 26 Jun 2002 13:21:01 -0000 Received: from unknown (HELO mta04ps.bigpond.com) (144.135.25.136) by sources.redhat.com with SMTP; 26 Jun 2002 13:21:01 -0000 Received: from bubble.local ([144.135.25.78]) by mta04ps.bigpond.com (Netscape Messaging Server 4.15 mta04ps Apr 29 2002 13:22:02) with SMTP id GYBEEZ00.AUJ for ; Wed, 26 Jun 2002 23:20:59 +1000 Received: from CPE-144-136-176-14.sa.bigpond.net.au ([144.136.176.14]) by PSMAM04.mailsvc.email.bigpond.com(MailRouter V3.0n 98/20600749); 26 Jun 2002 23:20:59 Received: (qmail 7446 invoked by uid 179); 26 Jun 2002 13:20:58 -0000 Date: Wed, 26 Jun 2002 06:21:00 -0000 From: Alan Modra To: binutils@sources.redhat.com Cc: Olaf Hering Subject: powerpc64 and "nm -C" Message-ID: <20020626132058.GW22093@bubble.sa.bigpond.net.au> Mail-Followup-To: binutils@sources.redhat.com, Olaf Hering Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.25i X-SW-Source: 2002-06/txt/msg00720.txt.bz2 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