doas apt install binutils
objdump -p adb | grep NEEDED
objdump -p $(which adb) | grep NEEDED
readelf -d adb
NEEDED libbase.so.0
NEEDED libcrypto.so.0
NEEDED libcutils.so.0
NEEDED libpthread.so.0
NEEDED libusb-1.0.so.0
NEEDED libstdc++.so.6
NEEDED libm.so.6
NEEDED libgcc_s.so.1
NEEDED libc.so.6
NEEDED ld-linux-x86-64.so.2
objdump -p adb
RUNPATH /usr/lib/x86_64-linux-gnu/android
change RUNPATH value
patchelf --set-rpath '$ORIGIN/../lib64' filename
# Clearing RPATH & RUNPATH
patchelf --remove-rpath <path-to-elf># Setting RPATH
patchelf --force-rpath --set-rpath <desired-rpath> <path-to-elf># Setting RUNPATH
patchelf --set-rpath <desired-rpath> <path-to-elf>
patchelf --set-interpreter <path-to-interpreter> <path-to-elf># For example:
>>If you specify--force-rpath
, setsRPATH
, otherwise setsRUNPATH
patchelf --print-interpreter adb
/lib64/ld-linux-x86-64.so.2
patchelf --print-rpath adb
/usr/lib/x86_64-linux-gnu/android
>>
dynamic loader = "ELF interpreter"=
example patchelf --print-interpreter $(which bash)
/lib64/ld-linux-x86-64.so.2
/lib64/ld-linux-x86-64.so.2 --help
Usage: /lib64/ld-linux-x86-64.so.2 [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]
You have invoked 'ld.so', the program interpreter for dynamically-linked
ELF programs. Usually, the program interpreter is invoked automatically
when a dynamically-linked executable is started.
You may invoke the program interpreter program directly from the command
line to load and run an ELF executable file; this is like executing that
file itself, but always uses the program interpreter you invoked,
instead of the program interpreter specified in the executable file you
run. Invoking the program interpreter directly provides access to
additional diagnostics, and changing the dynamic linker behavior without
setting environment variables (which would be inherited by subprocesses).
--list list all dependencies and how they are resolved
--verify verify that given object really is a dynamically linked
object we can handle
--inhibit-cache Do not use /etc/ld.so.cache
--library-path PATH use given PATH instead of content of the environment
variable LD_LIBRARY_PATH
--glibc-hwcaps-prepend LIST
search glibc-hwcaps subdirectories in LIST
--glibc-hwcaps-mask LIST
only search built-in subdirectories if in LIST
--inhibit-rpath LIST ignore RUNPATH and RPATH information in object names
in LIST
--audit LIST use objects named in LIST as auditors
--preload LIST preload objects named in LIST
--argv0 STRING set argv[0] to STRING before running
--list-tunables list all tunables with minimum and maximum values
--list-diagnostics list diagnostics information
--help display this help and exit
--version output version information and exit
This program interpreter self-identifies as: /lib64/ld-linux-x86-64.so.2
Shared library search path:
(libraries located via /etc/ld.so.cache)
/lib/x86_64-linux-gnu (system search path)
/usr/lib/x86_64-linux-gnu (system search path)
/lib (system search path)
/usr/lib (system search path)
Subdirectories of glibc-hwcaps directories, in priority order:
x86-64-v4 (supported, searched)
x86-64-v3 (supported, searched)
x86-64-v2 (supported, searched)
Legacy HWCAP subdirectories under library search path directories:
haswell (AT_PLATFORM; supported, searched)
tls (supported, searched)
avx512_1 (supported, searched)
x86_64 (supported, searched)
##load library from current folder
LD_LIBRARY_PATH=. ./adb shell
https://linux.die.net/man/8/ld.so
https://linux.die.net/man/1/ld
https://man7.org/linux/man-pages/man1/ldd.1.html
https://github.com/NixOS/patchelf/blob/master/README.md
https://trugman-internals.com/elf-loaders-libraries-executables/
https://www.hpc.dtu.dk/?page_id=1180
https://stackoverflow.com/questions/13769141/can-i-change-rpath-in-an-already-compiled-binary
http://xahlee.info/UnixResource_dir/_/ldpath.html
Comments
Post a Comment