This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] ld: -rpath/-rpath_link must search under sysroot
The -rpath and -rpath_link arguments 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.
Signed-off-by: Andy Ross <andy.ross@windriver.com>
---
ld/emultempl/elf32.em | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index de51050..79c5bca 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1257,15 +1257,23 @@ EOF
fi
fragment <<EOF
- if (gld${EMULATION_NAME}_search_needed (command_line.rpath_link,
- &n, force))
- break;
+ if (command_line.rpath_link) {
+ char *tmprp = gld${EMULATION_NAME}_add_sysroot (command_line.rpath_link);
+ found = gld${EMULATION_NAME}_search_needed (tmprp, &n, force);
+ free(tmprp);
+ if (found)
+ break;
+ }
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;
+ }
EOF
fi
if [ "x${NATIVE}" = xyes ] ; then
--
1.7.11.2