[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/18992] New: Linking a library implicitly using relative DT_RPATH
From: |
sourceware-bugzilla at jbeekman dot nl |
Subject: |
[Bug ld/18992] New: Linking a library implicitly using relative DT_RPATH does not work |
Date: |
Tue, 22 Sep 2015 22:55:09 +0000 |
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 ld/18992] New: Linking a library implicitly using relative DT_RPATH does not work,
sourceware-bugzilla at jbeekman dot nl <=
- [Bug ld/18992] Linking a library implicitly using relative DT_RPATH does not work, jwakely.gcc at gmail dot com, 2015/09/22
- [Bug ld/18992] Linking a library implicitly using relative DT_RPATH does not work, sourceware-bugzilla at jbeekman dot nl, 2015/09/22
- [Bug ld/18992] Linking a library implicitly using relative DT_RPATH does not work, vapier at gentoo dot org, 2015/09/22
- [Bug ld/18992] Linking a library implicitly using relative DT_RPATH does not work, amodra at gmail dot com, 2015/09/23
- [Bug ld/18992] Linking a library implicitly using relative DT_RPATH does not work, sourceware-bugzilla at jbeekman dot nl, 2015/09/23
- [Bug ld/18992] Linking a library implicitly using relative DT_RPATH does not work, amodra at gmail dot com, 2015/09/24
- [Bug ld/18992] Linking a library implicitly using relative DT_RPATH does not work, cvs-commit at gcc dot gnu.org, 2015/09/24