From 7ab82579bb29649768b675726bd1503d83aeaea6 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 2 Jul 2019 15:42:19 +0200 Subject: 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 --- hack/analyses/nm-symbols-analysis.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 hack/analyses/nm-symbols-analysis.sh (limited to 'hack') 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" -- cgit v1.2.3-54-g00ecf