I know there are many ways to remove/add library dependencies reported prior to compiling an executable for use in Linux. However, after a bit of searching I have not been able to find the way to bypass these dependencies when given only the executable and no binaries. For example, if I run ldd on the executable and there is a shared library that is not found and I do not think is necessary for the program to run.
Thank you
You could try patchElf, which is claimed to be "A small utility to modify the dynamic linker and RPATH of ELF executables"
Home page: http://nixos.org/patchelf.html. github repository: https://github.com/NixOS/patchelf
For example, if I run ldd on the executable and there is a shared library that is not found and I do not think is necessary for the program to run.
You can trivially test whether your belief is correct: create an empty "stub" shared library with the name that ldd
reports as not found, and test whether the executable runs correctly when you make use of that stub (e.g. via LD_LIBRARY_PATH
).
If the executable does in fact work (which is somewhat unlikely), you can binary-patch the .dynamic
section of the executable to remove the unnecessary dependency -- .dynamic
is simply a fixed-sized table of Elf{32,64}_Dyn
records, terminated by a record with .d_tag == DT_NULL
(the needed libraries are represented by records with .d_tag == DT_NEEDED
. You can therefore find the unnecessary record, and simply "slide" all following records one slot up in the table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With