This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [RESEND][PATCH] ld: -rpath must search under sysroot
[Apologies for the delay, I missed this over the weekend.]
On 09/07/2012 02:31 PM, Joseph S. Myers wrote:
On Thu, 6 Sep 2012, Andy Ross wrote:
This looks like it may change what happens when there is no RPATH option
at all. Previously, gld${EMULATION_NAME}_search_needed would still be
called even if command_line.rpath is NULL, and it in turn has logic:
[...]
which handles the name[0] == '/' case *before* returning in the NULL rpath
case. Is this an intentional change?
Indeed it was not, thanks. Fixed to restore original behavior absent
an rpath argument, and hopefully for whitespace conventions.
Andy
From 45397794df0b8daf45c924838c406a6d70224db9 Mon Sep 17 00:00:00 2001
From: Andy Ross <andy.ross@windriver.com>
Date: Tue, 21 Aug 2012 10:50:55 -0700
Subject: [PATCH] ld: -rpath must search under sysroot
The -rpath argument would search the host filesystem for libraries,
even when a sysroot was defined. For cross toolchains with targets
compatible with the host architecture this can find incorrect
libraries. Leave -rpath-link unmodified, as build systems in the wild
are already using this to point to host directories.
Signed-off-by: Andy Ross <andy.ross@windriver.com>
---
ld/emultempl/elf32.em | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index de51050..36d08f2 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1263,9 +1263,16 @@ fragment <<EOF
EOF
if [ "x${USE_LIBPATH}" = xyes ] ; then
fragment <<EOF
- if (gld${EMULATION_NAME}_search_needed (command_line.rpath,
- &n, force))
- break;
+ if (command_line.rpath)
+ {
+ char *tmprp = gld${EMULATION_NAME}_add_sysroot (command_line.rpath);
+ found = gld${EMULATION_NAME}_search_needed (tmprp, &n, force);
+ free (tmprp);
+ if (found)
+ break;
+ }
+ else if (gld${EMULATION_NAME}_search_needed (NULL, &n, force))
+ break;
EOF
fi
if [ "x${NATIVE}" = xyes ] ; then
--
1.7.11.4