This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

PATCH COMMITTED: Don't drop a space after a demangled name in collect2


collect2 automatically demangles the output of the linker.  It has
some code which is intended to preserve spacing.  However, this code
has a minor bug: if the demangled name is longer than the mangled name
(which is normally the case), but there aren't enough spaces following
the symbol name to make up the difference, thence collect2 won't print
any space at all.  The effect of this is that in an error message like
    symbol _Z3fooi is undefined
is demangled to
    symbol foo(int)is undefined

This is normally invisible with GNU ld because GNU ld normally quotes
all symbol names, so there is no trailing space.  However, I happened
to notice this problem with a different linker.

I committed this patch to fix the bug.  Bootstrapped and tested on
i686-pc-linux-gnu.

Ian


2007-11-16  Ian Lance Taylor  <iant@google.com>

	* collect2.c (dump_file): If a demangled symbol is followed by a
	space, make sure we output at least one space.


Index: collect2.c
===================================================================
--- collect2.c	(revision 130242)
+++ collect2.c	(working copy)
@@ -487,8 +487,18 @@ dump_file (const char *name, FILE *to)
 	      diff = strlen (word) - strlen (result);
 	      while (diff > 0 && c == ' ')
 		--diff, putc (' ', to);
-	      while (diff < 0 && c == ' ')
-		++diff, c = getc (stream);
+	      if (diff < 0 && c == ' ')
+		{
+		  while (diff < 0 && c == ' ')
+		    ++diff, c = getc (stream);
+		  if (!ISSPACE (c))
+		    {
+		      /* Make sure we output at least one space, or
+			 the demangled symbol name will run into
+			 whatever text follows.  */
+		      putc (' ', to);
+		    }
+		}
 
 	      free (result);
 	    }


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