summaryrefslogblamecommitdiffstats
path: root/useful/lddsize
blob: 1215f989e66cc2982fb579dc0068ff891402b0b6 (plain) (tree)

























                                                                                     
#!/bin/bash

# libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f0844776000)
if [ -e "$1" ]; then
	FILE="$1"
else
	FILE=$(which "$1")
fi

if [ ! -e "$FILE" ]; then
	echo "FILE NOT FOUND: $FILE" >&2
	exit 1
fi

SOS=$(ldd "$FILE" | sed -r 's/^[^=]*=> ([^ ]*) .*$/\1/g' | grep '^/')
SIZE=$(stat -c %s "$FILE")
LIBS=0
for SO in $SOS; do
	S=$(stat -c %s "$SO")
	SIZE=$(( $SIZE + $S ))
	LIBS=$(( $LIBS + 1 ))
done

SIZE=$(( $SIZE / 1024 ))
echo "$FILE has $LIBS shared libs with a total size of ${SIZE}KiB (including itself)"