RPATH or RUNPATH is a colon-separated list of directories embedded in an executable. This list of directories play an important role when shared library file locations are determined at the time when the executable is loaded for running. This process is described in this post. Note that RPATH has highest priority in the shared library search, compared to RUNPATH. We can change RPATH or RUNPATH of a binary file by using the chrpath tool.
- Installing this tool is easy:
$ sudo apt install chrpath
- To view if the binary has RPATH or RUNPATH and to list its colon-separated list of directories:
$ chrpath ./some_binary
- To remove RPATH or RUNPATH from the binary:
$ chrpath -d ./some_binary
- To convert RPATH of a binary to a RUNPATH:
$ chrpath -c ./some_binary
Note that you cannot convert a RUNPATH back to RPATH.
- To replace RPATH or RUNPATH paths with a different set of paths:
$ chrpath -r /home/joe:/home/foobar/lib64 ./some_binary
Note that the string of the new set of paths should be smaller or equal to the length of what was stored earlier in the binary.
Tried with: chrpath 0.14 and Ubuntu 16.04