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]

Re: powerpc64 and "nm -C"


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);


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