This is the mail archive of the 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] sysroot and Windows->Linux cross ld

In regards to a discussion about a bug on or about Jan 17 on the above subject, please find attached my patch.

I don't have write access to binutils at this time.

The problem was the ld expect libiberty/lrealpath() to always return a path, but in some cases it returns a prefix. It seemed like too much of an earthquake to propose a fix to lrealpath.

--Douglas Rupp

	* ldmain.c (main): Remove any trailing directory separator
	from ld_canon_sysroot and adjust ld_canon_sysroot_len.

diff --git ld/ldmain.c ld/ldmain.c
index e049de3..524b7cd 100644
--- ld/ldmain.c
+++ ld/ldmain.c
@@ -237,9 +237,17 @@ main (int argc, char **argv)
   if (*ld_sysroot)
     ld_canon_sysroot = lrealpath (ld_sysroot);
   if (ld_canon_sysroot)
-    ld_canon_sysroot_len = strlen (ld_canon_sysroot);
+    {
+      ld_canon_sysroot_len = strlen (ld_canon_sysroot);
+      /* is_sysrooted_pathname() relies on no trailing dirsep.  */
+      if (IS_DIR_SEPARATOR (ld_canon_sysroot [ld_canon_sysroot_len - 1]))
+        ld_canon_sysroot [--ld_canon_sysroot_len] = '\0';
+    }
-    ld_canon_sysroot_len = -1;
+    {
+      ld_canon_sysroot_len = -1;
+    }
   /* Set the default BFD target based on the configured target.  Doing
      this permits the linker to be configured for a particular target,

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