//PassManagerBuilder.cpp
#include"llvm/Transforms/Obfuscation/BogusControlFlow.h"#include"llvm/Transforms/Obfuscation/Flattening.h"#include"llvm/Transforms/Obfuscation/Split.h"#include"llvm/Transforms/Obfuscation/Substitution.h"#include"llvm/CryptoUtils.h"// Flags for obfuscation
staticcl::opt<bool>Flattening("fla",cl::init(false),cl::desc("Enable the flattening pass"));staticcl::opt<bool>BogusControlFlow("bcf",cl::init(false),cl::desc("Enable bogus control flow"));staticcl::opt<bool>Substitution("sub",cl::init(false),cl::desc("Enable instruction substitutions"));staticcl::opt<std::string>AesSeed("aesSeed",cl::init(""),cl::desc("seed for the AES-CTR PRNG"));staticcl::opt<bool>Split("spli",cl::init(false),cl::desc("Enable basic block splitting"));PassManagerBuilder::PassManagerBuilder(){//------------------------------------------
// Initialization of the global cryptographically
// secure pseudo-random generator
if(!AesSeed.empty()){llvm::cryptoutils->prng_seed(AesSeed.c_str());}}voidPassManagerBuilder::populateModulePassManager(legacy::PassManagerBase&MPM){MPM.add(createForceFunctionAttrsLegacyPass());//--------------
MPM.add(createSplitBasicBlock(Split));MPM.add(createBogus(BogusControlFlow));//注意,这个地方跟官方版本不一样,进行了修改
if(Flattening){MPM.add(createLowerSwitchPass());}MPM.add(createFlattening(Flattening));MPM.add(createSubstitution(Substitution));//--------------
}