/home/sc/m/obfuscator-llvm-9.0/lib/Transforms/Obfuscation/BogusControlFlow.cpp: In member function ‘bool {anonymous}::BogusControlFlow::doF(llvm::Module&)’: /home/sc/m/obfuscator-llvm-9.0/lib/Transforms/Obfuscation/BogusControlFlow.cpp:531:11: error: ‘TerminatorInst’ was not declared in this scope TerminatorInst * tbb= fi->getTerminator(); ^~~~~~~~~~~~~~ /home/sc/m/obfuscator-llvm-9.0/lib/Transforms/Obfuscation/BogusControlFlow.cpp:531:28: error: ‘tbb’ was not declared in this scope TerminatorInst * tbb= fi->getTerminator(); ^~~ [ 32%] Building CXX object lib/Transforms/Coroutines/CMakeFiles/LLVMCoroutines.dir/CoroSplit.cpp.o lib/Transforms/Obfuscation/CMakeFiles/LLVMObfuscation.dir/build.make:110: recipe for target 'lib/Transforms/Obfuscation/CMakeFiles/LLVMObfuscation.dir/BogusControlFlow.cpp.o' failed make[2]: *** [lib/Transforms/Obfuscation/CMakeFiles/LLVMObfuscation.dir/BogusControlFlow.cpp.o] Error 1 CMakeFiles/Makefile2:4510: recipe for target 'lib/Transforms/Obfuscation/CMakeFiles/LLVMObfuscation.dir/all' failed make[1]: *** [lib/Transforms/Obfuscation/CMakeFiles/LLVMObfuscation.dir/all] Error 2 solved:https://github.com/Magic-King/obfuscator/commit/13bb054888f5cac14f76308c8559a5cda021035d TerminatorInst 改为 Instruction TerminatorInst 继承于 Instruction 类 但是不知道为啥llvm9.0里没了 ------------------------ /home/sc/m/obfuscator-llvm-9.0/lib/Transforms/Obfuscation/Flattening.cpp: In member function ‘bool {anonymous}::Flattening::flatten(llvm::Function*)’: /home/sc/m/obfuscator-llvm-9.0/lib/Transforms/Obfuscation/Flattening.cpp:68:25: error: ‘createLowerSwitchPass’ was not declared in this scope FunctionPass *lower = createLowerSwitchPass(); ^~~~~~~~~~~~~~~~~~~~~ /home/sc/m/obfuscator-llvm-9.0/lib/Transforms/Obfuscation/Flattening.cpp:68:25: note: suggested alternative: ‘createPrinterPass’ FunctionPass *lower = createLowerSwitchPass(); 在文件头中加入这行 // fix createLowerSwitchPass() not declared #include "llvm/Transforms/Utils.h" 不知道他的宏定义 #define DEBUG_TYPE "flattening" using namespace llvm; 应该是这行不起作用了,然后他就炸了,找不到函数 ollvm-4.0 createPrinterPass() 定义在了include/llvm/Transforms/Scalar.h 并在 Flattening.h 中被 include 但是在llvm9.0中对应目录下的 Scalar.h 中没有该函数,故找不到该函数. 但是却能在llvm namespace里找到 另一种办法就是 在 Scalar.h 中声明该函数即可. //===------------------------------------------------------------------ ----===// // // LowerSwitch - This pass converts SwitchInst instructions into a sequ ence of // chained binary branch instructions. // FunctionPass *createLowerSwitchPass(); extern char &LowerSwitchID; ------------------------- /home/sc/m/obfuscator-llvm-9.0/lib/Transforms/Obfuscation/StringObfuscation.cpp: In member function ‘void llvm::StringObfuscationPass::addDecodeFunction(llvm::Module*, std::vector*)’: /home/sc/m/obfuscator-llvm-9.0/lib/Transforms/Obfuscation/StringObfuscation.cpp:141:102: error: cannot convert ‘llvm::FunctionCallee’ to ‘llvm::Constant*’ in initialization Constant* c = mod->getOrInsertFunction(".datadiv_decode" + random_str, FuncTy); ^ lib/Transforms/Obfuscation/CMakeFiles/LLVMObfuscation.dir/build.make:206: recipe for target 'lib/Transforms/Obfuscation/CMakeFiles/LLVMObfuscation.dir/StringObfuscation.cpp.o' failed make[2]: *** [lib/Transforms/Obfuscation/CMakeFiles/LLVMObfuscation.dir/StringObfuscation.cpp.o] Error 1 CMakeFiles/Makefile2:4510: recipe for target 'lib/Transforms/Obfuscation/CMakeFiles/LLVMObfuscation.dir/all' failed make[1]: *** [lib/Transforms/Obfuscation/CMakeFiles/LLVMObfuscation.dir/all] Error 2 make[1]: *** 正在等待未完成的任务.... [ 33%] Linking CXX static library ../../libLLVMipo.a [ 34%] Built target LLVMipo Makefile:151: recipe for target 'all' failed make: *** [all] Error 2 bug_log string obfuscation failed string obf can be use in ollvm-4.0 //error: cannot convert ‘llvm::FunctionCallee’ to ‘llvm::Constant*’ in initialization //fix bug //Constant* c = mod->getOrInsertFunction(".datadiv_decode" + random_str, FuncTy); //Function* fdecode = cast(c); mod->getOrInsertFunction(".datadiv_decode" + random_str, FuncTy); Function* fdecode = mod->getFunction(".datadiv_decode" + random_str); ------------------------- Stack dump: 0. Program arguments: /home/sc/m/build/bin/clang-9 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir /home/sc/m/build/lib/clang/9.0.0 -internal-isystem /usr/local/include -internal-isystem /home/sc/m/build/lib/clang/9.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/sc/m/test -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -mllvm -fla -faddrsig -o /tmp/test-8889c6.o -x c test.c 1. parser at end of file 2. Per-module optimization passes 3. Running pass 'Function Pass Manager' on module 'test.c'. 4. Running pass 'Call graph flattening' on function '@main' #0 0x000055a35411af4a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/sc/m/build/bin/clang-9+0x274ff4a) #1 0x000055a354118d14 llvm::sys::RunSignalHandlers() (/home/sc/m/build/bin/clang-9+0x274dd14) #2 0x000055a354118e52 SignalHandler(int) (/home/sc/m/build/bin/clang-9+0x274de52) #3 0x00007f89a0e0b890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890) #4 0x000055a3541f2008 (anonymous namespace)::LowerSwitch::runOnFunction(llvm::Function&) (/home/sc/m/build/bin/clang-9+0x2827008) #5 0x000055a354eb33b3 (anonymous namespace)::Flattening::runOnFunction(llvm::Function&) (/home/sc/m/build/bin/clang-9+0x34e83b3) #6 0x000055a353b10188 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/sc/m/build/bin/clang-9+0x2145188) #7 0x000055a353b10243 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/sc/m/build/bin/clang-9+0x2145243) #8 0x000055a353b0f4e1 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/sc/m/build/bin/clang-9+0x21444e1) #9 0x000055a35433e911 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr >) (/home/sc/m/build/bin/clang-9+0x2973911) #10 0x000055a3543405cb clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr >) (/home/sc/m/build/bin/clang-9+0x29755cb) #11 0x000055a354d47a01 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/sc/m/build/bin/clang-9+0x337ca01) #12 0x000055a3557c3a39 clang::ParseAST(clang::Sema&, bool, bool) (/home/sc/m/build/bin/clang-9+0x3df8a39) #13 0x000055a354d45457 clang::CodeGenAction::ExecuteAction() (/home/sc/m/build/bin/clang-9+0x337a457) #14 0x000055a3547eb399 clang::FrontendAction::Execute() (/home/sc/m/build/bin/clang-9+0x2e20399) #15 0x000055a3547ae835 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/sc/m/build/bin/clang-9+0x2de3835) #16 0x000055a3548ae083 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/sc/m/build/bin/clang-9+0x2ee3083) #17 0x000055a352653df3 cc1_main(llvm::ArrayRef, char const*, void*) (/home/sc/m/build/bin/clang-9+0xc88df3) #18 0x000055a3525bd4d9 main (/home/sc/m/build/bin/clang-9+0xbf24d9) #19 0x00007f899fa9fb97 __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0 #20 0x000055a3526514ba _start (/home/sc/m/build/bin/clang-9+0xc864ba) clang-9: error: unable to execute command: Segmentation fault (core dumped) clang-9: error: clang frontend command failed due to signal (use -v to see invocation) Obfuscator-LLVM clang version 9.0.0 (tags/RELEASE_900/final) (based on Obfuscator-LLVM 9.0.0) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/sc/m/test/../build/bin clang-9: note: diagnostic msg: PLEASE submit a bug report to https://o-llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. clang-9: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-9: note: diagnostic msg: /tmp/test-827834.c clang-9: note: diagnostic msg: /tmp/test-827834.sh clang-9: note: diagnostic msg: ******************** fla依旧失败 --------------------------------