summaryrefslogtreecommitdiffstats
path: root/useful/lddsize
diff options
context:
space:
mode:
authorSimon Rettberg2013-12-18 18:15:34 +0100
committerSimon Rettberg2013-12-18 18:15:34 +0100
commitb90f8bd14cb7246d0be0207c4d843d7a40a5e624 (patch)
treedde18da4de38fdcc89c4b46aba5555170cc3c309 /useful/lddsize
parentMerge branch 'master' of dnbd3:openslx-ng/tm-scripts (diff)
downloadtm-scripts-b90f8bd14cb7246d0be0207c4d843d7a40a5e624.tar.gz
tm-scripts-b90f8bd14cb7246d0be0207c4d843d7a40a5e624.tar.xz
tm-scripts-b90f8bd14cb7246d0be0207c4d843d7a40a5e624.zip
Two tiny scripts for copying/analyzing binaries and their shared libs
Diffstat (limited to 'useful/lddsize')
-rwxr-xr-xuseful/lddsize26
1 files changed, 26 insertions, 0 deletions
diff --git a/useful/lddsize b/useful/lddsize
new file mode 100755
index 00000000..1215f989
--- /dev/null
+++ b/useful/lddsize
@@ -0,0 +1,26 @@
+#!/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)"
+