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] Relative DT_RPATH/DT_RUNPATH vs. sysroot capable ld.


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

commit 3074964fcfff45aef4584b84550eeef84f902fc4
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Sep 24 13:13:57 2015 +0930

    Relative DT_RPATH/DT_RUNPATH vs. sysroot capable ld.
    
    This fixes two problems.  First, the --sysroot option wasn't available
    with a ld configured without --with-sysroot, a historical accident.
    This led to people configuring binutils with --with-sysroot=/ in order
    to enable sysroot support, which exposes a case where ld wrongly
    prepends the sysroot to a relative path.
    
    	PR ld/18992
    	* ldmain.c (main): Always enable --sysroot.
    	* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Don't
    	prepend sysroot to relative rpath/runpath.

Diff:
---
 ld/ChangeLog          |  7 +++++++
 ld/emultempl/elf32.em |  8 ++++++--
 ld/ldmain.c           | 10 +---------
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 3b69e31..9b664d0 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2015-09-24  Alan Modra  <amodra@gmail.com>
+
+	PR ld/18992
+	* ldmain.c (main): Always enable --sysroot.
+	* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Don't
+	prepend sysroot to relative rpath/runpath.
+
 2015-09-23  Nick Clifton  <nickc@redhat.com>
 
 	* emultempl/elf32.em (ehdr_start_empty): New static variable.
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index ea6d48c..8ff5fe0 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1256,12 +1256,16 @@ fragment <<EOF
 	  rp = bfd_elf_get_runpath_list (link_info.output_bfd, &link_info);
 	  for (; !found && rp != NULL; rp = rp->next)
 	    {
-	      char *tmpname = gld${EMULATION_NAME}_add_sysroot (rp->name);
+	      const char *tmpname = rp->name;
+
+	      if (IS_ABSOLUTE_PATH (tmpname))
+		tmpname = gld${EMULATION_NAME}_add_sysroot (tmpname);
 	      found = (rp->by == l->by
 		       && gld${EMULATION_NAME}_search_needed (tmpname,
 							      &n,
 							      force));
-	      free (tmpname);
+	      if (tmpname != rp->name)
+		free ((char *) tmpname);
 	    }
 	  if (found)
 	    break;
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 577928d..96d7fe8 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -222,15 +222,7 @@ main (int argc, char **argv)
   /* Set up the sysroot directory.  */
   ld_sysroot = get_sysroot (argc, argv);
   if (*ld_sysroot)
-    {
-      if (*TARGET_SYSTEM_ROOT == 0)
-	{
-	  einfo ("%P%F: this linker was not configured to use sysroots\n");
-	  ld_sysroot = "";
-	}
-      else
-	ld_canon_sysroot = lrealpath (ld_sysroot);
-    }
+    ld_canon_sysroot = lrealpath (ld_sysroot);
   if (ld_canon_sysroot)
     ld_canon_sysroot_len = strlen (ld_canon_sysroot);
   else


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