This determines the size of stack frames in a binary by inspecting the sub %rsp
instructions in a very crude way.
It might be incorrect on account of not all functions using the stack the same way or consistently.
objdump -d target/release/materialized \
| grep 'sub.*rsp$\|>:' \
| sed -n '$!N;/sub/P;D' \
| grep "sub " -1 \
| paste -d " " - - \
| awk '{print $NF " " $2}' \
| grep "^\$0x" \
| cut -c 4- \
| sed 's/,/ /' \
| perl -ne'print hex $_; print " "; print $_' \
| sort -n
Let's go over its part to figure out what it does:
objdump -d target/release/materialized
Disassemble all symbols in the.text
section.grep 'sub.*rsp$\|>:'
Find all lines that containsub.*rsp
(allocating a stack frame) or>:
(indicating a symbol).sed -n '$!N;/sub/P;D'
Not suregrep "sub " -1
Find all lines containingsub
and print it including the preceding line.paste -d " " - -
Concat every two lines into one.awk '{print $NF " " $2}'
Print column 2 and then the whole linegrep "^\$0x"
Only print lines that start with a hex code.cut -c 4-
Trim off the hex0x
header.sed 's/,/ /'
Replace,
by a space.perl -ne'print hex $_; print " "; print $_'
Convert the hex number to a decimal.sort -n
Sort numerically.