summaryrefslogtreecommitdiffstats
path: root/scripts/check_size
blob: 54f02a63c5efd44c76b650645fd0821ddaf3f1b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

symbol="$1"
file="$2"
max="$3"

# extract symbol offset from file, remove leading zeros
ofs=$(nm -t d $file | grep "$symbol" | cut -d ' ' -f1 | sed "s/^[0]*//")

if [ -z "${ofs}" ]; then
	echo "symbol $symbol not found in $file"
	exit 1
fi

if [[ $ofs -gt $max ]]; then
	echo "symbol $symbol (offset $ofs) in $file exceeds maximum offset $max"
	exit 1
fi

exit 0