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>
This commit is contained in:
Valentin Rothberg 2019-07-02 15:42:19 +02:00
parent aa28dbbf88
commit 7ab82579bb
1 changed files with 15 additions and 0 deletions

View File

@ -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"