If "=" is the first character in a ldscript input file, force a sysroot prefix.
authorHans-Peter Nilsson <hp@bitrange.com>
Wed, 15 Oct 2014 01:03:59 +0000 (03:03 +0200)
committerHans-Peter Nilsson <hp@bitrange.com>
Wed, 15 Oct 2014 01:04:21 +0000 (03:04 +0200)
* ldlang.c (lang_add_input_file): If the first character in the
filename is '=', prepend the sysroot and force the context of that
input file to non-sysroot.

The "input_flags.sysrooted = 0" thing described in the comment is
covered by the testsuite part ("root-anchored =-prefixed script
inside"), but only observable for --with-sysroot configurations.

ld/ChangeLog
ld/ldlang.c

index dd7c75e341e33cabb72fa31b336c6d8de7603845..49a0a669280ddf2a632ecf23cfc8feb4c842858b 100644 (file)
@@ -1,5 +1,8 @@
 2014-10-15  Hans-Peter Nilsson  <hp@axis.com>
 
+       * ldlang.c (lang_add_input_file): If the first character in the
+       filename is '=', prepend the sysroot and force the context of that
+       input file to non-sysroot.
        * ld.texinfo (Options): When mentioning "=" and sysroot, mention
        that --sysroot controls it, not only through the configuration.
        (input files in linker scripts): When mentioning
index 5960e5c89aacacaa4a1ca3b1ba37c3343e1929a6..c4da07f5013fb40197796b266bb0aae2254e346d 100644 (file)
@@ -1118,6 +1118,26 @@ lang_add_input_file (const char *name,
                     lang_input_file_enum_type file_type,
                     const char *target)
 {
+  if (name != NULL && *name == '=')
+    {
+      lang_input_statement_type *ret;
+      char *sysrooted_name
+       = concat (ld_sysroot, name + 1, (const char *) NULL);
+
+      /* We've now forcibly prepended the sysroot, making the input
+        file independent of the context.  Therefore, temporarily
+        force a non-sysrooted context for this statement, so it won't
+        get the sysroot prepended again when opened.  (N.B. if it's a
+        script, any child nodes with input files starting with "/"
+        will be handled as "sysrooted" as they'll be found to be
+        within the sysroot subdirectory.)  */
+      unsigned int outer_sysrooted = input_flags.sysrooted;
+      input_flags.sysrooted = 0;
+      ret = new_afile (sysrooted_name, file_type, target, TRUE);
+      input_flags.sysrooted = outer_sysrooted;
+      return ret;
+    }
+
   return new_afile (name, file_type, target, TRUE);
 }
 
This page took 0.02772 seconds and 4 git commands to generate.