[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gold/15098] New: DT_RPATH isn't set with -rpath on Linux
From: |
hjl.tools at gmail dot com |
Subject: |
[Bug gold/15098] New: DT_RPATH isn't set with -rpath on Linux |
Date: |
Tue, 05 Feb 2013 01:42:36 +0000 |
http://sourceware.org/bugzilla/show_bug.cgi?id=15098
Bug #: 15098
Summary: DT_RPATH isn't set with -rpath on Linux
Product: binutils
Version: 2.24 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: gold
AssignedTo: address@hidden
ReportedBy: address@hidden
CC: address@hidden
Classification: Unclassified
According to gABI,
The set of directories specified by a given DT_RUNPATH entry is used to
find only the immediate dependencies of the executable or shared object
containing the DT_RUNPATH entry. That is, it is used only for those
dependencies contained in the DT_NEEDED entries of the dynamic structure
containing the DT_RUNPATH entry, itself. One object's DT_RUNPATH entry
does not affect the search for any other object's dependencies.
That means DT_RUNPATH on executable doesn't apply to shared objects
which executable depends on:
address@hidden pr15096a]$ cat foo.c
#include <stdio.h>
#include <dlfcn.h>
int
main ()
{
typedef int (*hello_t)();
hello_t hello1;
void* handle = dlopen("libso1.so", RTLD_LAZY);
if (!handle)
{
printf ("dlopen: %s\n", dlerror ());
return 1;
}
hello1 = (hello_t)dlsym(handle, "hello1");
hello1();
return 0;
}
address@hidden pr15096a]$ cat so1.c
extern void hello2 (void);
void
hello1 (void)
{
hello2();
}
address@hidden pr15096a]$ cat so2.c
#include <stdio.h>
void
hello2 ()
{
printf ("hello\n");
}
address@hidden pr15096a]$ make
gcc -fPIC -O2 -shared -o libso2.so so2.c
gcc -fPIC -O2 -shared -o libso1.so so1.c libso2.so
gcc -B./ -o foo2 foo.c -Wl,-rpath,. -ldl
readelf -d foo2
Dynamic section at offset 0x890 contains 26 entries:
Tag Type Name/Value
0x0000000000000003 (PLTGOT) 0x401a88
0x0000000000000002 (PLTRELSZ) 120 (bytes)
0x0000000000000017 (JMPREL) 0x400488
0x0000000000000014 (PLTREL) RELA
0x0000000000000007 (RELA) 0x400470
0x0000000000000008 (RELASZ) 24 (bytes)
0x0000000000000009 (RELAENT) 24 (bytes)
0x0000000000000015 (DEBUG) 0x0
0x0000000000000006 (SYMTAB) 0x400260
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000005 (STRTAB) 0x400350
0x000000000000000a (STRSZ) 171 (bytes)
0x000000006ffffef5 (GNU_HASH) 0x400400
0x0000000000000001 (NEEDED) Shared library: [libdl.so.2]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000c (INIT) 0x400500
0x000000000000000d (FINI) 0x400784
0x000000000000001a (FINI_ARRAY) 0x401ad8
0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
0x0000000000000019 (INIT_ARRAY) 0x401ae0
0x000000000000001b (INIT_ARRAYSZ) 8 (bytes)
0x000000000000001d (RUNPATH) Library runpath: [.]
0x000000006ffffff0 (VERSYM) 0x40041c
0x000000006ffffffe (VERNEED) 0x400430
0x000000006fffffff (VERNEEDNUM) 2
0x0000000000000000 (NULL) 0x0
./foo2
dlopen: libso2.so: cannot open shared object file: No such file or directory
make: *** [all] Error 1
address@hidden pr15096a]$
This is introduced by
http://sourceware.org/git/?p=binutils.git;a=commit;h=0e0646ad6f21c4d6230c31f452b73f133f4b5777
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug gold/15098] New: DT_RPATH isn't set with -rpath on Linux,
hjl.tools at gmail dot com <=