Skip to content

Instantly share code, notes, and snippets.

@FreeSlave
Last active December 31, 2023 05:24
Show Gist options
  • Select an option

  • Save FreeSlave/e63f8f776e70a0a99e12530100fa1868 to your computer and use it in GitHub Desktop.

Select an option

Save FreeSlave/e63f8f776e70a0a99e12530100fa1868 to your computer and use it in GitHub Desktop.
Various aliases to deal with shared libraries
# get first level dependencies (without dependencies of dependencies)
depends() {
many=0; [ "$#" -gt 1 ] && many=1
while [[ "$#" -gt 0 ]]; do
if [ "$many" == 1 ]; then
echo -e "\n$1 depends on:"
fi
objdump -p "$1" | grep NEEDED | tr -s ' ' | cut -d ' ' -f 3
shift
done
}
# get soname
soname() {
many=0; [ "$#" -gt 1 ] && many=1
while [[ "$#" -gt 0 ]]; do
libsoname="$(objdump -p "$1" | grep SONAME | tr -s ' ' | cut -d ' ' -f 3)"
if [ "$many" == 1 ]; then
echo "soname of $1: $libsoname"
else
echo "$libsoname"
fi
shift
done
}
# find absolute paths to the globally installed library
findlibs() {
/sbin/ldconfig -p | rev | cut -f1 -d' ' | rev | grep "$1"
}
findlib() {
findlibs "$1" | head -n 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment