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

[binutils-gdb] Remove any trailing directory separator from ld_canon_sysroot and adjust ld_canon_sysroot_len.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=889be5dbd230ee47a90d4a83f682b13ed7e3faae

commit 889be5dbd230ee47a90d4a83f682b13ed7e3faae
Author: Douglas B Rupp <rupp@adacore.com>
Date:   Wed Feb 28 11:44:26 2018 +0000

    Remove any trailing directory separator	from ld_canon_sysroot and adjust ld_canon_sysroot_len.
    
    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.
    
    	* ldmain.c (main): Remove directory separator, if any, from the
    	end of the canonicalized sysroot.

Diff:
---
 ld/ChangeLog | 5 +++++
 ld/ldmain.c  | 9 ++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 07c86ef..f6b7508 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-28  Douglas B Rupp  <rupp@adacore.com>
+
+	* ldmain.c (main): Remove directory separator, if any, from the
+	end of the canonicalized sysroot.
+
 2018-02-27  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* NEWS: Mention --enable-separate-code.
diff --git a/ld/ldmain.c b/ld/ldmain.c
index b6914db..6527613 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -228,7 +228,14 @@ 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 (ld_canon_sysroot_len > 0
+	  && IS_DIR_SEPARATOR (ld_canon_sysroot [ld_canon_sysroot_len - 1]))
+        ld_canon_sysroot [--ld_canon_sysroot_len] = '\0';
+    }
   else
     ld_canon_sysroot_len = -1;


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