4 ms·
I've never seen that linker trick before to avoid rewriting rpaths! Very cool
by stabbles 5y ago
I've never seen that linker trick before to avoid rewriting rpaths! Very cool
- stabbles 5y agoHow does this work when locating libraries recursively though? It seems --inhibit-rpath only applies to the current executable: # Create a.out <- one/libx.so <- one/sub/liby.so $ echo 'int g(){return 42;}' | gcc -shared -o one/sub/liby.so -x c - $ echo 'extern int g(); int f(){return g();}' | gcc -shared -o one/libx.so -x c - -Lone/sub -ly '-Wl,-rpath,$ORIGIN/sub' $ echo 'extern int f(); int main(){return f();}' | gcc -x c - -Lone -lx '-Wl,-rpath,$ORIGIN/one' # works fine $ ./a.out $ echo $? 42 # can't locate library through rpath with --inhibit-rpath $ /lib64/ld-linux-x86-64.so.2 --inhibit-rpath '' ./a.out ./a.out: error while loading shared libraries: libx.so: cannot open shared object file: No such file or directory # *does* locate liby.so through rpath! $ /lib64/ld-linux-x86-64.so.2 --inhibit-rpath '' --library-path ./a.out $ echo $? 42