Skip to content

Instantly share code, notes, and snippets.

@artemdinaburg
Created November 24, 2014 03:58
Show Gist options
  • Save artemdinaburg/b9e50b7ef754afacd739 to your computer and use it in GitHub Desktop.
Save artemdinaburg/b9e50b7ef754afacd739 to your computer and use it in GitHub Desktop.
Use mcsema to convert a maze binary to LLVM bitcode
# These directions will:
# 1. Build a binary version of the Symbolic Maze by Felipe Manzano
# 2. Convert the binary to LLVM bitcode with mcsema
# 3. Optimize the resulting LLVM bitcode
#
# These same actions are done by
# ~/klee/mcsema/mc-sema/tests/demo_maze.sh
# if you would like to run them automatically
cd ~/klee/mcsema/mc-sema/tests
# Load our environment variables
source env.sh
# Compile the demo to a 32-bit ELF executable
${CC} -ggdb -m32 -o demo_maze demo_maze.c
# Recover the CFG using mcsema's bin_descend
${BIN_DESCEND_PATH}/bin_descend_wrapper.py -d -func-map=maze_map.txt -i=demo_maze -entry-symbol=main
# Convert the CFG into LLVM bitcode via mcsema's cfg_to_bc
${CFG_TO_BC_PATH}/cfg_to_bc -i demo_maze.cfg -driver=mcsema_main,main,raw,return,C -o demo_maze.bc
# Optimize the bitcode
${LLVM_PATH}/opt -O3 -o demo_maze_opt.bc demo_maze.bc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment