Is there any way to change the SONAME of a binary directly? Is there any way to change the SONAME of a binary directly? linux linux

Is there any way to change the SONAME of a binary directly?


Yes, you can use patchelf like this (from its Readme):

patchelf --set-soname libnewname.so.3.4.5 path/to/libmylibrary.so.1.2.3


You should avoid removing the version of the SO object, as for example when your application depends on a specific libc (libc.so.6).

The proper way to do it, if you want to use another lib is using the LD_PRELOAD variable before calling your application

If you set LD_PRELOAD to the path of the new file, that file will be loaded before any other library (including even C runtime, libc.so).