This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

powerpc64 and "nm -C"


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]