Before you use NIONKA-LLVM
Obtain LLVM 2.6. Current version of NIONKA-LLVM is based on LLVM 2.6. Please make sure that you download the correct version and do not conflict with other versions of LLVM on your machine.
Visit http://llvm.org/release/download.html and download following packages:
- LLVM-GCC 4.2 Front End for LLVM 2.6 version
- LLVM 2.6 source code
Build LLVM source code.
- Create a customized pass directory for our analysis. I suggest you to put our LLVM pass source code directory in "to-llvm-dir/lib/Transforms/" directory and add our new directory into Makefile file under this directory.
- Build our customized Ehj pass. If succeed, a library file start with LLVMEhj will appear on directory "to-llvm-dir/Release/lib/" or "to-llvm-dir/Debug/lib/" depends on what build option you choose for LLVM.
Use NIONKA-LLVM to instrument your code
Use LLVM-GCC Front End to build your code into bytecode and link your code into a single bytecode file. Assume the file is named "code.bc".
Use opt tool of LLVM to instrument code.bc
$ opt -load "to-llvm-dir/Release/lib/LLVMEhj.so" -ehj code.bc > instrumented.bc
This will create a instrumented bytecode file "instrumented.bc".
Link instrumented code with our Ehj library bytecode file "ehjlib.bc".
$ llvm-link instrumented.bc ehjlib.bc -o linked.bc
Compile assembly file from LLVM bytecode and use gcc to build executable file.
$ llc linked.bc -o linked.s
$ gcc -s linked.s -o a.out
Now "a.out" is an executable instrumented file.
If the outputs in Step 4 and Step 5 are correct then you have a successfully installed NIONKA.
How to use NIONKA
Set up configure file in your working directory. Create a "branchFile.txt" file and put a basic block ID you want to flip. You can find the map from BB ID to BB name in output of Step 1. We also allow you to create a list of BB ID as stopping criterion for hijacked execution. Once the execution reaches thess BBs, the execution will be terminated.
Run the executable file generated in previous steps with inputs.