Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rpath of a shared object file

The rpath of an executable specifies one or more directories wherein to look for shared objects at runtime.

My question is - do shared object files themselves also have statically-compiled rpaths?

I recently received a runtime error when linking with a shared object:

./example: /opt/swt/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by ./mylib.so)

This error indicates to me that the actually library itself - mylib.so, has an statically compiled rpath.

My understanding was that rpath only applied to executables, not shared objects. So does rpath also apply to shared objects?

like image 283
Siler Avatar asked May 21 '15 16:05

Siler


1 Answers

do shared object files themselves also have statically-compiled rpaths

They may (or may not) depending on whether they were linked with -Wl,-rpath=... option.

This error indicates to me that the actually library itself - mylib.so, has an statically compiled rpath.

The error message does not say that at all. Where did you get that idea?

If you want to know whether mylib.so has DT_RPATH or not, do this:

readelf -d mylib.so | grep 'R.*PATH'  # could also have RUNPATH

My understanding was that rpath only applied to executables, not shared objects. So does rpath also apply to shared objects?

Your understanding is incorrect, and RPATH (and RUNPATH) works for shared objects just as well.

like image 126
Employed Russian Avatar answered Sep 17 '22 13:09

Employed Russian