Skip to content

Instantly share code, notes, and snippets.

@kth5
Last active December 11, 2022 00:07
Show Gist options
  • Save kth5/728ef3fc3661c2066d22287eb56adc6e to your computer and use it in GitHub Desktop.
Save kth5/728ef3fc3661c2066d22287eb56adc6e to your computer and use it in GitHub Desktop.
Simple script to find binaries and shared objects missing direct linked libraries (readelf vs ldd) with pacman support
#!/bin/bash
SOLIBS=$(find /usr/lib -maxdepth 1 -type f -name "*.so.*")
BINS=$(find /usr/bin -maxdepth 1 -type f)
for file in ${SOLIBS[@]} ${BINS[@]}; do
sobump=0
for solib in $(readelf -d ${file} 2>&1 | grep NEEDED | awk '{print $5}' | sed -e 's@\[@@g' -e 's@\]@@g' | sort -u); do
if [ ! -f /usr/lib/${solib} -a ! -f /usr/lib/*/${solib} ]; then
pkg=$(pacman -Qqo ${file})
echo "${file} BAD: ${pkg} ${solib}";
sobump=1
fi
done
[ ${sobump} -eq 0 ] && echo "${file} OK"
done
@kth5
Copy link
Author

kth5 commented Dec 11, 2022

Avoids ldd automatically resolving linked libraries and only finds directly linked objects missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment