This is the mail archive of the binutils@sources.redhat.com 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]

ld doesn't relocate sysroot if called as tooldir/bin/ld


This patch fixes the problem above.  I wasn't sure whether to try to
find the sys-root starting at toolbindir or bindir first, but ended up
deciding for searching bindir first, since toolbindir and GCC's
default sysroot are siblings, so toolbindir would be more likely to
find a false match.

Ok to install?


Along the same lines...  What would people think of arranging for
pathnames in linker scripts within the sysroot to have the sysroot
pathname prepended to them?  This would solve the main problem of
relocating a cross toolchain with a glibc sysroot, because the glibc
linker scripts reference full pathnames in the real root.  Comments?

Index: ld/ChangeLog
from  Alexandre Oliva  <aoliva at redhat dot com>

	* Makefile.am (ldmain.o): Define TOOLBINDIR.
	* Makefile.in: Rebuilt.
	* ldmain.c (ld_sysroot): Try to set from TOOLBINDIR too.

Index: ld/Makefile.am
===================================================================
RCS file: /cvs/uberbaum/ld/Makefile.am,v
retrieving revision 1.123
diff -u -p -r1.123 Makefile.am
--- ld/Makefile.am 18 Feb 2003 06:05:06 -0000 1.123
+++ ld/Makefile.am 20 Feb 2003 10:05:35 -0000
@@ -397,6 +397,7 @@ po/POTFILES.in: @MAINT@ Makefile
 ldmain.o: ldmain.c config.status
 	$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
 	  -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
+	  -DTOOLBINDIR='"$(tooldir)/bin"' \
 	  -DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
 	  $(srcdir)/ldmain.c
 
Index: ld/ldmain.c
===================================================================
RCS file: /cvs/uberbaum/ld/ldmain.c,v
retrieving revision 1.62
diff -u -p -r1.62 ldmain.c
--- ld/ldmain.c 17 Feb 2003 18:24:37 -0000 1.62
+++ ld/ldmain.c 20 Feb 2003 10:05:36 -0000
@@ -199,6 +199,7 @@ main (argc, argv)
 #ifdef TARGET_SYSTEM_ROOT_RELOCATABLE
   ld_sysroot = make_relative_prefix (program_name, BINDIR,
 				     TARGET_SYSTEM_ROOT);
+
   if (ld_sysroot)
     {
       struct stat s;
@@ -206,10 +207,26 @@ main (argc, argv)
       if (!res)
 	{
 	  free (ld_sysroot);
-	  ld_sysroot = TARGET_SYSTEM_ROOT;
+	  ld_sysroot = NULL;
 	}
     }
-  else
+
+  if (! ld_sysroot)
+    ld_sysroot = make_relative_prefix (program_name, TOOLBINDIR,
+				       TARGET_SYSTEM_ROOT);
+
+  if (ld_sysroot)
+    {
+      struct stat s;
+      int res = stat (ld_sysroot, &s) == 0 && S_ISDIR (s.st_mode);
+      if (!res)
+	{
+	  free (ld_sysroot);
+	  ld_sysroot = NULL;
+	}
+    }
+
+  if (! ld_sysroot)
     ld_sysroot = TARGET_SYSTEM_ROOT;
 #else
   ld_sysroot = TARGET_SYSTEM_ROOT;
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva at {redhat dot com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva at {lsd dot ic dot unicamp dot br, gnu.org}
Free Software Evangelist                Professional serial bug killer

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