]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
013-03-08 Joey Ye <joey.ye@arm.com>
authorJoey Ye <joey.ye@arm.com>
Fri, 8 Mar 2013 07:25:09 +0000 (07:25 +0000)
committerJoey Ye <jye2@gcc.gnu.org>
Fri, 8 Mar 2013 07:25:09 +0000 (07:25 +0000)
    Backport from mainline
    2013-03-06  Joey Ye  <joey.ye@arm.com>

    PR lto/50293
    * gcc.c (convert_white_space): New function.
    (main): Handles white space in function name.

From-SVN: r196534

gcc/ChangeLog
gcc/gcc.c

index 73651dd22dd420fadfdaa862ff759913404d71c4..9c68a7e1aad877b8f7c6b6c5163d4ce184b0894e 100644 (file)
@@ -1,3 +1,12 @@
+2013-03-08  Joey Ye  <joey.ye@arm.com>
+
+       Backport from mainline
+       2013-03-06  Joey Ye  <joey.ye@arm.com>
+
+       PR lto/50293
+       * gcc.c (convert_white_space): New function.
+       (main): Handles white space in function name.
+
 2013-03-06  Oleg Endo  <olegendo@gcc.gnu.org>
 
        Backport from mainline
index 29d26cd6144c8d496fc88e82a984f8574c71ea9e..939dcc8735fc0a959e4299cd7297efddf943c4dc 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -267,6 +267,7 @@ static const char *compare_debug_dump_opt_spec_function (int, const char **);
 static const char *compare_debug_self_opt_spec_function (int, const char **);
 static const char *compare_debug_auxbase_opt_spec_function (int, const char **);
 static const char *pass_through_libs_spec_func (int, const char **);
+static char *convert_white_space (char *);
 \f
 /* The Specs Language
 
@@ -6506,6 +6507,7 @@ main (int argc, char **argv)
                                    X_OK, false);
   if (lto_wrapper_file)
     {
+      lto_wrapper_file = convert_white_space (lto_wrapper_file);
       lto_wrapper_spec = lto_wrapper_file;
       obstack_init (&collect_obstack);
       obstack_grow (&collect_obstack, "COLLECT_LTO_WRAPPER=",
@@ -6916,12 +6918,13 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
                              + strlen (fuse_linker_plugin), 0))
 #endif
            {
-             linker_plugin_file_spec = find_a_file (&exec_prefixes,
-                                                    LTOPLUGINSONAME, R_OK,
-                                                    false);
-             if (!linker_plugin_file_spec)
+             char *temp_spec = find_a_file (&exec_prefixes,
+                                            LTOPLUGINSONAME, R_OK,
+                                            false);
+             if (!temp_spec)
                fatal_error ("-fuse-linker-plugin, but %s not found",
                             LTOPLUGINSONAME);
+             linker_plugin_file_spec = convert_white_space (temp_spec);
            }
 #endif
          lto_gcc_spec = argv[0];
@@ -8376,3 +8379,51 @@ pass_through_libs_spec_func (int argc, const char **argv)
     }
   return prepended;
 }
+
+/* Insert backslash before spaces in ORIG (usually a file path), to 
+   avoid being broken by spec parser.
+
+   This function is needed as do_spec_1 treats white space (' ' and '\t')
+   as the end of an argument. But in case of -plugin /usr/gcc install/xxx.so,
+   the file name should be treated as a single argument rather than being
+   broken into multiple. Solution is to insert '\\' before the space in a 
+   file name.
+   
+   This function converts and only converts all occurrence of ' ' 
+   to '\\' + ' ' and '\t' to '\\' + '\t'.  For example:
+   "a b"  -> "a\\ b"
+   "a  b" -> "a\\ \\ b"
+   "a\tb" -> "a\\\tb"
+   "a\\ b" -> "a\\\\ b"
+
+   orig: input null-terminating string that was allocated by xalloc. The
+   memory it points to might be freed in this function. Behavior undefined
+   if ORIG wasn't xalloced or was freed already at entry.
+
+   Return: ORIG if no conversion needed. Otherwise a newly allocated string
+   that was converted from ORIG.  */
+
+static char *
+convert_white_space (char *orig)
+{
+  int len, number_of_space = 0;
+
+  for (len = 0; orig[len]; len++)
+    if (orig[len] == ' ' || orig[len] == '\t') number_of_space++;
+
+  if (number_of_space)
+    {
+      char *new_spec = (char *) xmalloc (len + number_of_space + 1);
+      int j, k;
+      for (j = 0, k = 0; j <= len; j++, k++)
+       {
+         if (orig[j] == ' ' || orig[j] == '\t')
+           new_spec[k++] = '\\';
+         new_spec[k] = orig[j];
+       }
+      free (orig);
+      return new_spec;
+  }
+  else
+    return orig;
+}