public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@bigpond.net.au>
To: binutils@sources.redhat.com
Cc: Olaf Hering <olh@suse.de>
Subject: powerpc64 and "nm -C"
Date: Wed, 26 Jun 2002 06:21:00 -0000	[thread overview]
Message-ID: <20020626132058.GW22093@bubble.sa.bigpond.net.au> (raw)

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

             reply	other threads:[~2002-06-26 13:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-26  6:21 Alan Modra [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020626132058.GW22093@bubble.sa.bigpond.net.au \
    --to=amodra@bigpond.net.au \
    --cc=binutils@sources.redhat.com \
    --cc=olh@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).