retdec
|
#include <value_protect.h>
Public Member Functions | |
ValueProtect () | |
virtual bool | runOnModule (llvm::Module &M) override |
bool | runOnModuleCustom (llvm::Module &M, Config *c, Abi *abi) |
Static Public Attributes | |
static char | ID = 0 |
Private Member Functions | |
bool | run () |
bool | protect () |
bool | protectStack () |
bool | protectRegisters (bool skipCalledFunctions=true) |
bool | protectLoadStores () |
bool | unprotect () |
void | protectValue (llvm::Value *val, llvm::Type *t, llvm::Instruction *before) |
llvm::Function * | getOrCreateFunction (llvm::Type *t) |
llvm::Function * | createFunction (llvm::Type *t) |
Private Attributes | |
llvm::Module * | _module = nullptr |
Config * | _config = nullptr |
Abi * | _abi = nullptr |
Static Private Attributes | |
static std::map< llvm::Type *, llvm::Function * > | _type2fnc |
Generates patterns like this at functions' entry BBs:
Where XYZ are allocated variables (registers, stacks).
This is done to protect these variables from aggressive LLVM optimizations. This way, stacks are not uninitialized, and registers are not equal to their initialization values.
Every even run generates these protections. Every odd run removes them (partially, see https://github.com/avast/retdec/issues/301).
retdec::bin2llvmir::ValueProtect::ValueProtect | ( | ) |
|
private |
|
private |
|
private |
|
private |
Replace loads/stores from/to undef/nullptr values by special intrinsic functions. These loads and stores would be recognized by LLVM optimization passes and they would cause "abort() // UNREACHABLE" pattern in the output C.
|
private |
|
private |
|
private |
|
private |
True
if module _module was modified in any way, false
otherwise.
|
overridevirtual |
bool retdec::bin2llvmir::ValueProtect::runOnModuleCustom | ( | llvm::Module & | M, |
Config * | c, | ||
Abi * | abi | ||
) |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
static |