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]

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


On Thu, Feb 20, 2003 at 07:10:06AM -0300, Alexandre Oliva wrote:
> 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?

Hmm, you're doing a duplicate stat; could you try to avoid that?  It's
easy, just means a little more indentation.

I also just want to throw out another thought: with the patch I posted
to gcc-patches earlier today, if we made the version in TOOLBINDIR a
symlink to the one in BINDIR instead of a hardlink, it would work
automatically.  I don't know if that's a good solution though.  I'm not
terribly worried about the potential for false positives, so I think
what you have is fine.

> 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?

Oooh.  I love it.  That'd kill one of the last truly gross hacks in my
cross tool setup.


> 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


-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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