mm/tools/calc_bss.sh
EllipticEllipsis b245740020
CRC files OK and documented (#409)
* crc.c OK and documented

* chmod calc_bss.sh and add base dir to includes

* Port voicecrc work, add documentation

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Add full stop

* Review

* Format

* Add some more `!= 0`s

* size_t

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
2021-11-11 15:03:05 -03:00

43 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# Given a list of header files, compute the bss index that results from
# including them. (See prevent_bss_reordering.h for more information.)
TEMPC=$(mktemp -t bss.XXXXXXX.c)
TEMPO=$(mktemp -t bss.XXXXXXX.o)
trap "rm -f $TEMPC $TEMPO" EXIT
set -e
if [[ $# = 0 ]]; then
echo "Usage: ./tools/calc_bss.sh file1.h file2.h ..." >&2
exit 1
fi
if [ -z "$CROSS" ]; then
CROSS=mips-linux-gnu-
fi
# bss indexing starts at 3
for I in {3..255}; do
echo "char bss$I;" >> $TEMPC
done
for I in {0..2}; do
echo "char bss$I;" >> $TEMPC
done
while [[ $# -gt 0 ]]; do
echo "#include \"$1\"" >> $TEMPC
shift
done
echo "char measurement;" >> $TEMPC
$(pwd)/tools/ido_recomp/linux/7.1/cc -G 0 -non_shared \
-Xfullwarn -Xcpluscomm -O2 -g3 -Xcpluscomm -mips2 \
-I $(pwd)/ -I $(pwd)/include/ -I $(pwd)/src/ -I $(pwd)/assets/ -I $(pwd)/build/ \
-Wab,-r4300_mul -woff 624,649,838,712 -c $TEMPC -o $TEMPO
LINE=$(${CROSS}objdump -t $TEMPO | grep measurement | cut -d' ' -f1)
NUM=$((0x$LINE - 1))
echo "bss index: $NUM"