LLVM ModulePass that adds code for performing CFG-fault detection at runtime.
Assuming that the code to which apply the pass has been generated in C:
- The functions marked as static are assumed to have only one entry point, i.e. it is not possible to reach them from a function different than main();
- If a function is not marked as static the verification is performed only within the function itself;
- The code works only with a patch that has to be applied to the
BasicBLock.cppfile (see the related LLVM issue here) - The callback function with signature
void cfg_err_detected()is assumed to be present in the codebase, it is the function that is called as soon as a CFG fault is detected.
An example of a C file compiled before and after the pass is present into the examples folder.