Last active
July 23, 2024 14:43
-
-
Save gonoph/84bbd137fb62a6a2c1d5ba1b27e635e6 to your computer and use it in GitHub Desktop.
getldd - script to recursively extract all the shared libraries of an elf executable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# usage: ./getldd mybinary | |
# will hard copy all the shared libs to | |
DEPS=/tmp/deps.txt | |
getldd() { | |
for i in $(ldd $1 | grep / | xargs echo) ; do | |
test -r "$i" && realpath "$i" && getldd $i | |
done | |
} | |
realpath $1 > $DEPS | |
getldd $1 | sort -u >> $DEPS | |
cat<<EOF | |
All the deps: | |
###### | |
$(cat $DEPS) | |
###### | |
To copy all the deps, do something like: | |
for i in \$(cat $DEPS) ; do mkdir -p /tmp/mydest/\$(dirname \$i) && cp -va \$i /tmp/mydest/\$i ; done | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
modified script to use the absolute filename.
Also included the binary on the command line as part of the list of dependencies to simplify the output logic.