summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-07-02 15:42:19 +0200
committerValentin Rothberg <rothberg@redhat.com>2019-07-16 14:16:16 +0200
commit7ab82579bb29649768b675726bd1503d83aeaea6 (patch)
treec0d0bd581cd1c56dc7cbb04a9e497b2e2997bea6
parentaa28dbbf8876bd749379ba9540d7cc103bd56291 (diff)
downloadpodman-7ab82579bb29649768b675726bd1503d83aeaea6.tar.gz
podman-7ab82579bb29649768b675726bd1503d83aeaea6.tar.bz2
podman-7ab82579bb29649768b675726bd1503d83aeaea6.zip
add hack/analyses/nm-symbols-analysis.sh
The script allows for analyzing the symbols of a go binary passed as an argument. The tabular output looks as follows: 336 unicode/utf8.DecodeLastRune 323 unicode/utf8.DecodeLastRuneInString 518 unicode/utf8.DecodeRune 518 unicode/utf8.DecodeRuneInString 337 unicode/utf8.EncodeRune The first column indicates the size in bytes of the symbol in the second column. Note that only text symbols are considered, other symbols from the data or the bss segment are ignored to avoid information overload. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
-rwxr-xr-xhack/analyses/nm-symbols-analysis.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/hack/analyses/nm-symbols-analysis.sh b/hack/analyses/nm-symbols-analysis.sh
new file mode 100755
index 000000000..924246715
--- /dev/null
+++ b/hack/analyses/nm-symbols-analysis.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/bash
+
+if test "$#" -ne 1; then
+ echo "invalid arguments: usage: $0 path/to/binary"
+ exit 1
+fi
+
+DATA=$(go tool nm -size "$1" \
+ | awk 'NF==4 {printf "%s\t%s\t%s\n", $2, $3, $4}' \
+ | grep -v -P "\t_\t" \
+ | grep -P "\tt\t" \
+ | awk ' {printf "%s\t\t%s\n", $1, $3} ' \
+ )
+
+echo "$DATA"