This is the mail archive of the binutils@sourceware.org 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]

[PATCH 5/6] If "=" is the first character in a script input file, force a sysroot prefix.


The core change of the proposal; align script input files with
SEARCH_DIR semantics.  Yes, 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:
	* 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.

diff --git a/ld/ldlang.c b/ld/ldlang.c
index 899f710..411b379 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -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);
 }
 
-- 
brgds, H-P


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