Target Program Compilation

To analyze a program with ScEpTIC, we first need to produce its LLVM IR completed with debug information.

For doing so, we first compile each .c file of our project with clang, 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 clang-8.0 instead of clang.

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.

Now, we should have a .ll LLVM IR file for each source file of our project. As next step, we need to link all the .ll files together:

llvm-link -S file1.ll file2.ll -o program.ll

As a result, we now have a program.ll file, which contains the LLVM IR of our program. Note that if our program consists only in one source file, we do not need to execute the llvm-link command.

Finally, if we use the default configuration of ScEpTIC, we need to specify in our source code the attribute section in each variable declaration that we want to allocate onto NVM. For example, if we want to allocate onto NVM the variable x, we need to declare it as:

int x __attribute__((section(".NVM"))) = ...;