KLEE是斯坦福大学开发的符号执行工具,其功能强大。基于LLVM的中间语言IR进行符号执行分析。本章介绍KLEE的安装和基本使用。
要在您的计算机上本机运行Docker,您需要使用安装了Docker的Linux发行版。 请按照以下链接获取有关Ubuntu,OS X和Windows的安装说明。
要下载特定Docker镜像的最新版本,请运行:
$ docker pull klee/klee
要下载特定TAG的KLEE版本,请运行:
$ docker pull klee/klee:<TAG>
$ docker run --rm -ti --ulimit='stack=-1:-1' klee/klee
输入如下命令,成为klee用户:
klee@3c098b05ca85:~$ whoami
klee
klee@3c098b05ca85:~$
在容器内运行KLEE
klee@3c098b05ca85:~$ klee --version
KLEE 1.0.0 (https://klee.github.io)
Built Sep 21 2015 (17:03:14)
Build mode: Release+Asserts
Build revision: unknown
LLVM (http://llvm.org/):
LLVM version 3.4
Optimized build.
Built Mar 5 2014 (17:05:10).
Default target: x86_64-pc-linux-gnu
Host CPU: core-avx2
查看Clang
$ clang --version
Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix
退出容器
klee@3c098b05ca85:~$ exit
输入命令
$ docker run -ti --name=my_first_klee_container --ulimit='stack=-1:-1' klee/klee
进入容器内的klee
klee@3c098b05ca85:~$ pwd
/home/klee
klee@3c098b05ca85:~$ echo "int main(int argn, char** argv) { return 0; }" > test.c
klee@3c098b05ca85:~$ clang -emit-llvm -g -c test.c -o test.bc
klee@3c098b05ca85:~$ klee --libc=uclibc --posix-runtime test.bc
KLEE: NOTE: Using klee-uclibc : /home/klee/klee_build/klee/Release+Asserts/lib/klee-uclibc.bca
KLEE: NOTE: Using model: /home/klee/klee_build/klee/Release+Asserts/lib/libkleeRuntimePOSIX.bca
KLEE: output directory is "/home/klee/klee-out-0"
KLEE: WARNING: undefined reference to function: klee_posix_prefer_cex
KLEE: WARNING ONCE: calling external: syscall(16, 0, 21505, 44070352)
KLEE: WARNING ONCE: calling __user_main with extra arguments.
KLEE: done: total instructions = 5047
KLEE: done: completed paths = 1
KLEE: done: generated tests = 1
klee@3c098b05ca85:~$ ls
klee-last klee-out-0 klee_build klee_src test.bc test.c
喜欢本文就收藏吧,禁止非授权复制。
给作者留言