首先参考官网 http://klee.github.io/klee/
然后参考了这篇博客 http://www.tuicool.com/articles/ZvQBn2r
还参考了这篇博客 http://www.verydemo.com/demo_c288_i96986.html
第一步切换到家目录,建立工作路径
cd ~ mkdir software cd software mkdir KLEE cd KLEE
然后下载依赖包
sudo apt-get update sudo apt-get install g++ curl dejagnu subversion bison flex bc libcap-dev # Ubuntu
然后下载安装LLVM-GCC
wget http://llvm.org/releases/2.9/llvm-gcc4.2-2.9-x86_64-linux.tar.bz2 tar jxvf llvm-gcc4.2-2.9-x86_64-linux.tar.bz2然后设置环境变量
echo "export C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu" >> ~/.bashrc echo "export CPLUS_INCLUDE_PATH=/usr/include/x86_64-linux-gnu" >> ~/.bashrc echo "export PATH=$PATH:$HOME/software/KLEE/llvm-gcc4.2-2.9-x86_64-linux/bin" >> ~/.bashrc使环境变量生效
source ~/.bashrc
wget http://llvm.org/releases/2.9/llvm-2.9.tgz tar -zxvf llvm-2.9.tgz cd llvm-2.9 ./configure --enable-optimized --enable-assertions make cd ..然后下载并安装STP
wget http://www.doc.ic.ac.uk/~cristic/klee/stp-r940.tgz tar -zxvf stp-r940.tgz cd stp-r940 mkdir install ./scripts/configure --with-prefix=`pwd`/install --with-cryptominisat2 make OPTIMIZE=-O2 CFLAGS_M32= install cd ..
下载并安装KLEE-uclibc
git clone https://github.com/klee/klee-uclibc.git cd klee-uclibc ./configure --with-llvm-config $HOME/software/KLEE/llvm-2.9/Release+Asserts/bin/llvm-config --make-llvm-lib make -j2 cd ..下载并安装KLEE
git clone https://github.com/klee/klee.git cd klee ./configure --with-llvm=$HOME/software/KLEE/llvm-2.9 --with-stp=$HOME/software/KLEE/stp-r940/install --with-uclibc=$HOME/software/KLEE/klee-uclibc --enable-posix-runtime make ENABLE_OPTIMIZED=1 make check //可能会报错,不影响 make unittests测试例子
cd $HOME/software/KLEE/klee/examples/get_sign llvm-gcc -I ../../include --emit-llvm -c -g get_sign.c ../../Release+Asserts/bin/klee get_sign.o