As @ user7610 said, the right way is the patchelf tool.
But I feel that I can give a more complete answer, covering all the commands necessary to accomplish just that.
If you want to read a detailed explanation on this, you can find more information here .
First of all, many developers talk about RPATH , but in fact they mean RUNPATH . These are two different optional dynamic partitions, and the loader handles them in completely different ways. You can read more about the difference between the two in the link I mentioned earlier.
In the meantime, just remember:
- If
RUNPATH set, RPATH ignored. RPATH deprecated and should be avoided.RUNPATH is preferred because it can be overridden by LD_LIBRARY_PATH
See current R [UN] PATH
readelf -d <path-to-elf> | egrep "RPATH|RUNPATH"
Clear path R [UN]
patchelf --remove-rpath <path-to-elf>
Notes:
- Removes both
RPATH and RUNPATH
Add values ββto R [UN] PATH
patchelf [--force-rpath] --set-rpath "<desired-rpath>" <path-to-elf>
Notes:
<desired-path> is a comma-separated list of directories, for example: /my/libs: /my/other/libs- If you specify
--force-rpath , sets RPATH , otherwise sets RUNPATH
Daniel Trugman Feb 16 '19 at 13:18 2019-02-16 13:18
source share