https://sourceware.org/bugzilla/show_bug.cgi?id=18992
Bug ID: 18992
Summary: Linking a library implicitly using relative DT_RPATH
does not work
Product: binutils
Version: 2.24
Status: NEW
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: sourceware-bugzilla at jbeekman dot nl
Target Milestone: ---
I have a shared library ./dir/liba.so and a shared library ./libb.so with
DT_RPATH "dir" and DT_NEEDED "liba.so". Now, if I compile an executable with
-L. -lb, I get: "warning: liba.so, needed by ./libb.so, not found (try using
-rpath or -rpath-link)". It works when using an absolute DT_RPATH or when using
gold. The resulting binary works with a relative RPATH.
Here's a test case:
===> a.c <===
void a() {}
===> b.c <===
extern void a();
void b() {a();}
===> main.c <===
extern void b();
void main() {b();}
$ mkdir dir
$ gcc -fPIC -shared a.c -o dir/liba.so
# Make libb with relative RPATH
$ gcc -fPIC -shared -Ldir -Wl,-rpath,dir b.c -la -o libb.so
# Fail linking in relative-RPATH libb with ld.bfd
$ gcc main.c -L. -Wl,-rpath,. -lb -o main
/usr/bin/ld.bfd.real: warning: liba.so, needed by ./libb.so, not found (try
using -rpath or -rpath-link)
./libb.so: undefined reference to `a'
collect2: error: ld returned 1 exit status
# Succeed linking in relative-RPATH libb with gold
$ gcc main.c -fuse-ld=gold -L. -Wl,-rpath,. -lb -o main
# Run binary with relative-RPATH libb
$ ./main
# Make libb with absolute RPATH
$ gcc -fPIC -shared -Ldir -Wl,-rpath,$(pwd)/dir b.c -la -o libb.so
# Succeed linking in absolute-RPATH libb with ld.bfd
$ gcc main.c -L. -Wl,-rpath,. -lb -o main
# Run binary with absolute-RPATH libb
$ ./main
# Make libb with relative RPATH
$ gcc -fPIC -shared -Ldir -Wl,-rpath,dir b.c -la -o libb.so
# Run binary with relative-RPATH libb
$ ./main
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
bug-binutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-binutils