aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl/elf32.em
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2015-09-24 13:13:57 +0930
committerAlan Modra <amodra@gmail.com>2015-09-24 22:35:04 +0930
commit3074964fcfff45aef4584b84550eeef84f902fc4 (patch)
tree64869957c144cf643bfcee734e9e08a84682e83d /ld/emultempl/elf32.em
parent938d3bf25b2f5bc1a9d955d86070e8bbee127f52 (diff)
downloadgdb-3074964fcfff45aef4584b84550eeef84f902fc4.zip
gdb-3074964fcfff45aef4584b84550eeef84f902fc4.tar.gz
gdb-3074964fcfff45aef4584b84550eeef84f902fc4.tar.bz2
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.
Diffstat (limited to 'ld/emultempl/elf32.em')
-rw-r--r--ld/emultempl/elf32.em8
1 files changed, 6 insertions, 2 deletions
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;