-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.cpp
32 lines (29 loc) · 1.15 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <llvm/Passes/PassBuilder.h>
#include <llvm/Passes/PassPlugin.h>
#include <llvm/Support/raw_ostream.h>
#include "common.hpp"
#include "FuncAnnotationsParser.hpp"
#include "ObfuscationPassManager.hpp"
namespace obfusc {
llvm::PassPluginLibraryInfo getObfuscPluginInfo() {
llvm::outs() << "ObfusC Version: " << OBFUSC_VERSION_STR << "\n";
return {LLVM_PLUGIN_API_VERSION, "ObfusC", OBFUSC_VERSION_STR,
[](llvm::PassBuilder &PB) {
PB.registerPipelineEarlySimplificationEPCallback(
[=](llvm::ModulePassManager &MPM, llvm::OptimizationLevel Level) {
MPM.addPass(obfusc::FuncAnnotationsParser());
}
);
PB.registerOptimizerLastEPCallback(
[=](llvm::ModulePassManager &MPM, llvm::OptimizationLevel Level) {
MPM.addPass(obfusc::ObfuscationPassManager());
}
);
}
};
}
}
// Dynamic Library Entrypoint
extern "C" LLVM_ATTRIBUTE_WEAK llvm::PassPluginLibraryInfo llvmGetPassPluginInfo() {
return obfusc::getObfuscPluginInfo();
}