Following may be necessary on Ubuntu systems:
sudo apt-get install libsqlite3-dev
sudo apt install python3-clang
cd /usr/include
sudo ln -s asm-generic/ asm
The following python packages are also required:
kiwisolver
llvmlite
cmsis-svd
cycler
LLVM-12 is recommended as the version of KLEE and SVF we will use were tested on LLVM 12.
You can use build_llvm12.sh
Set to path for convenience:
export PATH=$(realpath llvm_12/llvm-12.0.0.obj/bin):$PATH
You will need this custom version of KLEE:
git clone [email protected]:akulpillai/klee.git --branch looper
When building use llvm 12:
cd klee
mkdir build
cd build
cmake -DLLVM_LIBS=$(realpath ../../llvm_12/llvm-12.0.0.obj/lib/libLLVM-12.so) -DCMAKE_BUILD_TYPE=Release ..
make -j12
git clone [email protected]:purs3lab/ArduSVF.git
export LLVM_DIR=$(realpath llvm_12/llvm-12.0.0.obj)
cd ArduSVF
./build.sh debug
You will need the bitcode file of the firmware you want to generate signatures for.
Set the following environment variables:
export PATH=$(realpath klee/build/bin):$PATH
export SYMEX=$(realpath ArduSVF/Debug-build/bin/symex)
export SVF=$(realpath ArduSVF/Debug-build/bin/svf-ex)
export NO_RUN=1 # optional SVF analysis, disabled by default
Make sure to update the bitcode file path and SVD file path in the following.
cd partitioner
cat << 'EOF' > conf.json
{
"firmware": {
"bc": "/home/akul/arducopter.bc",
"symex_bc": "/home/akul/arducopter.bc",
"platform": "stm32f4",
"svd_file": "/workdisk/akul/fire2/Pieces/partitioner/cmsis-svd-data/data/STMicro/STM32F401.svd",
"svd": "STM32F401",
"os": "unknown"
}
}
EOF
./init_files.sh
python3 classify.py conf.json <mangled_function_name>