bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/23727] New: ld with custom sysroot ignores rpath


From: nehaljw.kkd1 at gmail dot com
Subject: [Bug binutils/23727] New: ld with custom sysroot ignores rpath
Date: Sun, 30 Sep 2018 08:20:39 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=23727

            Bug ID: 23727
           Summary: ld with custom sysroot ignores rpath
           Product: binutils
           Version: 2.32 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: binutils
          Assignee: unassigned at sourceware dot org
          Reporter: nehaljw.kkd1 at gmail dot com
  Target Milestone: ---

Created attachment 11284
  --> https://sourceware.org/bugzilla/attachment.cgi?id=11284&action=edit
Potential fix for the bug

Compile binutils with a custom sysroot

address@hidden play]# ls libs/
libA.c  libA.so  libB.c  libB.so

address@hidden play]# ldd libs/libB.so
        linux-vdso.so.1 =>  (0x00007ffece150000)
        libA.so => /root/play/libs/libA.so (0x00007fcf50166000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fcf4fd99000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fcf5056a000)

address@hidden play]# cc play.c -lB -L$PWD/libs -Wl,-rpath,$PWD/libs
/ld/bin/ld: warning: libA.so, needed by /root/play/libs/libB.so, not found (try
using -rpath or -rpath-link)
/root/play/libs/libB.so: undefined reference to `libA'
collect2: error: ld returned 1 exit status

Running strace on the above command reveals that the linker looks for libA.so
in the custom sysroot directory + the specified rpath:
 /opt/conda/x86_64-conda_cos6-linux-gnu/sysroot/root/play/libs
But doesn't look at /root/play/libs

The bug affects all versions after ~28.1 . A git bisect reveals that the commit
causing this is:

address@hidden binutils-gdb]# git show
118aa6cf395aec093fe12d7fb2d05441791a93fa
commit 118aa6cf395aec093fe12d7fb2d05441791a93fa
Author: Alan Modra <address@hidden>
Date:   Sat Mar 11 23:37:02 2017 +1030

    Add sysroot for ld -rpath search

        * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Add
        sysroot for -rpath search.

diff --git a/ld/ChangeLog b/ld/ChangeLog
index f4baea8..86d9378 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,10 @@
 2017-03-11  Alan Modra  <address@hidden>

+       * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Add
+       sysroot for -rpath search.
+
+2017-03-11  Alan Modra  <address@hidden>
+
        * emultempl/elf32.em (gld${EMULATION_NAME}_add_sysroot): Rewrite.
        Only prefix absolute paths with sysroot.  Handle DOS paths.
        (gld${EMULATION_NAME}_check_ld_elf_hints): Constify variable.
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 16220d5..d4837d0 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1446,7 +1446,9 @@ fragment <<EOF
          path = command_line.rpath;
          if (path)
            {
+             path = gld${EMULATION_NAME}_add_sysroot (path);
              found = gld${EMULATION_NAME}_search_needed (path, &n, force);
+             free ((char *) path);
              if (found)
                break;
            }

I have attached a fix for this, although I am not sure if that's the right way
to solve this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]