Target Program Compilation
To execute a given program, ScEpTIC requires the LLVM IR of the source files enriched with debug information. In principle, ScEpTIC supports any source language whose compiler works with the LLVM toolchain, such as C (clang) and rust (cargo). However, we tested ScEpTIC only with clang.
Clang
To produce the LLVM IR of your source.c file with clang, you need to compile it as follows:
clang -emit-llvm -S -g source.c
where the -g option generates the debug information and the –emit-llvm -S options tells clang to produce the LLVM IR.
Note that in some systems you may need to write the full path of your clang-12.0
binary instead of clang
.
Once the compilation step completes, clang outputs a source.ll file, that is, the LLVM IR file simulated by ScEpTIC during system emulation.
If you need to specify an optimization pass or an optimization level, you can also use such options when generating the LLVM IR with clang.
Clang - linking multiple files
If your project consists of multiple .c files, you need to compile all of them, as specified above.
Then, you need to link all the generated .ll files together using llvm-link
or lli:
llvm-link -S file1.ll file2.ll -o program.ll
where the -S option tells llvm-link to produce the LLVM IR and program.ll
is the output file.
Note that in some systems you may need to write the full path of your llvm-link
binary instead of llvm-link
.
Once the linking step completes, llvm-link outputs a program.ll file, that is, the LLVM IR file simulated by ScEpTIC during system emulation.