forked from tzafrir/boa
-
Notifications
You must be signed in to change notification settings - Fork 1
/
boa
executable file
·51 lines (46 loc) · 1.56 KB
/
boa
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
BOADIR=`dirname $0`
files=""
args=""
BOA_SO="$BOADIR/build/boa.so"
CLANG="$BOADIR/../llvm/Debug+Asserts/bin/clang"
OPT="$BOADIR/../llvm/Debug+Asserts/bin/opt"
FLAGS=""
mem2reg="-mem2reg"
for arg in $@
do
if [ "${arg:0:16}" == "-safe_functions=" -o "${arg:0:18}" == "-unsafe_functions=" ]; then
FLAGS="$FLAGS $arg"
continue
fi
# Bash switch statement:
case "$arg" in
-log)
args="$args -logfile /dev/stderr"
;;
-nomem2reg)
mem2reg=""
;;
-output_glpk|-blame|-no_pointer_analysis|-ignore_literals|-v)
FLAGS="$FLAGS $arg"
;;
*)
files="$files $arg"
;;
esac
done
if [ "$files" != "" ]; then
$CLANG -g -O0 -c -emit-llvm ${files} -o /dev/stdout | $OPT -load $BOA_SO $args $mem2reg -boa $FLAGS > /dev/null
else
echo -e " usage : \033[1m./boa [flags] <source files>\033[0m"
echo ""
echo "possible flags - "
echo -e " \033[1m-log\033[0m - print log to stdout"
echo -e " \033[1m-v\033[0m - verbose output"
echo -e " \033[1m-blame\033[0m - print a set of constraints that cause each overrun"
echo -e " \033[1m-glpk\033[0m - pring glpk to log"
echo -e " \033[1m-no_pointer_analysis\033[0m - do not generate pointer analysis constraints"
echo -e " \033[1m-ignore_literals\033[0m - don't report buffer overruns on string literals"
echo -e " \033[1m-safe_functions\033[0m - comma separated list of safe function names"
echo -e " \033[1m-unsafe_functions\033[0m - comma separated list of unsafe function names"
fi