-
Notifications
You must be signed in to change notification settings - Fork 1
/
sizes.sh
executable file
·25 lines (18 loc) · 911 Bytes
/
sizes.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh
# Print out the sizes of functions in a linked executable that came
# from libqcbor.a. This doesn't work on ".a" because it gets confused
# by the separate ".o" files in the ".a". This can work on ".o" files,
# but only those are to be part of libqcbor.a
fun=`nm libqcbor.a | awk '/ [TtSs] /{printf "%s|", $3 }'; echo xxxxxxxxxxxxxx`
# It is not possible to get the size of the last symbol because nm
# doesn't output the end of the last item in the list. This is
# usually not an issue when run against an executable because there is
# only one function of the whole linked library left off.
nm -n -t d -U $1 |\
grep ' [TtSs] ' |\
awk 'NR!=1{printf "%-40s %4s\n", name, $1 - offset }
{offset=$1; name=$3}' |\
egrep $fun |\
sort -r -n -k 2 | tee /tmp/sizex_sh.$$
cat /tmp/sizex_sh.$$ | awk '{sum += $2} END {print "total " sum}'
rm -f /tmp/sizex_sh.$$