I have tried to do this:
patchelf --set-interpreter ../lib/ld-linux-x86-64.so.2 "${APPDIR}/usr/bin/myapp"
so I have this:
readelf -l AppDir/usr/bin/myapp
...
[Requesting program interpreter: ../lib/ld-linux-x86-64.so.2]
But it looks like it does not like the relative path as I get the error:
$ AppDir/usr/bin/myapp
bash: AppDir/usr/bin/myapp: No such file or directory
I have found this question, as I tried to solve this by using $ORIGIN
: Using $ORIGIN to specify the interpreter in ELF binaries isn't working, but it does not answer my question.
Is there a simple way to patch an executable with your certain linker, if you could not know beforehand its absolute path on a machine (e.g. if it's an appimage case)? The only workaround I know is to use path/to/my/ld.so --library-path <path/to/my/libs> path/to/my/exe
. But I am just curious, if there is a way to actually patch an executable, so that I could launch it directly?