Open fighting300 opened 7 years ago
seem like ollvm donnot support "@synchronized"。。。
@fighting300 bcf
DOES NOT support llvm invoke
instruction.
try...catch
, synchronized
and few other language internal implementations would generate invoke instruction.
You can filter out functions that contains InvokeInst
before running bcf
, just like what fla
does.
Any other information on how to troubleshoot this? Having the same issue and lowering bcf_prob to near 0 fixes it. @xelzmm Are you suggesting adding logic in the obfuscator.cpp file to ignore those invokes?
3 ways to fix this:
1&2 just skip and ignore the problem which will make BCF useless on some code but 3 actually do resolve the issue.
@xelzmm assuming you mean this: https://github.com/obfuscator-llvm/obfuscator/blob/llvm-4.0/lib/Transforms/Obfuscation/BogusControlFlow.cpp#L180-L183 recompiled it with some logic to skip on that invoke instruction but seems to still be hanging with bcf_prob higher than about 20. compiles fine on smaller projects/functions
for (Function::iterator i = F.begin(); i != F.end(); ++i) {
BasicBlock *bb = &*i;
if (!(isa<InvokeInst>(bb->getTerminator()))) {
basicBlocks.push_back(&*i);
}
}
if you want to skip some blocks instead of the whole function, then skip the normalDest of InvokeInst, which should be a block containing LandingPadInst, not Invoke block itself.
CompileC /Users/leon/Library/Developer/Xcode/DerivedData/QPatch-gvmpfbziiefwslesfbaeoapqwxkb/Build/Intermediates/QPatch.build/Debug-iphoneos/QPatch.build/Objects-normal/armv7/QTradeStart.o QPatch/Patch/Patch/QTradeStart.m normal armv7 objective-c com.apple.compilers.llvm.obfuscator.4_0 cd /Users/leon/Desktop/Code/ComCode/Patch/qpatch export LANG=en_US.US-ASCII export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Users/leon/Desktop/Code/GitCode/build/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-cache-path=/Users/leon/Library/Developer/Xcode/DerivedData/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/leon/Library/Developer/Xcode/DerivedData/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wunreachable-code -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DDEBUG=1 -DBETA_BUILD=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -miphoneos-version-min=6.0 -g -Wno-sign-conversion -Wno-infinite-recursion -fembed-bitcode-marker -iquote /Users/leon/Library/Developer/Xcode/DerivedData/QPatch-gvmpfbziiefwslesfbaeoapqwxkb/Build/Intermediates/QPatch.build/Debug-iphoneos/QPatch.build/QPatch-generated-files.hmap -I/Users/leon/Library/Developer/Xcode/DerivedData/QPatch-gvmpfbziiefwslesfbaeoapqwxkb/Build/Intermediates/QPatch.build/Debug-iphoneos/QPatch.build/QPatch-own-target-headers.hmap -I/Users/leon/Library/Developer/Xcode/DerivedData/QPatch-gvmpfbziiefwslesfbaeoapqwxkb/Build/Intermediates/QPatch.build/Debug-iphoneos/QPatch.build/QPatch-all-target-headers.hmap -iquote /Users/leon/Library/Developer/Xcode/DerivedData/QPatch-gvmpfbziiefwslesfbaeoapqwxkb/Build/Intermediates/QPatch.build/Debug-iphoneos/QPatch.build/QPatch-project-headers.hmap -I/Users/leon/Library/Developer/Xcode/DerivedData/QPatch-gvmpfbziiefwslesfbaeoapqwxkb/Build/Products/Debug-iphoneos/include -I/Users/leon/Library/Developer/Xcode/DerivedData/QPatch-gvmpfbziiefwslesfbaeoapqwxkb/Build/Intermediates/QPatch.build/Debug-iphoneos/QPatch.build/DerivedSources/armv7 -I/Users/leon/Library/Developer/Xcode/DerivedData/QPatch-gvmpfbziiefwslesfbaeoapqwxkb/Build/Intermediates/QPatch.build/Debug-iphoneos/QPatch.build/DerivedSources -F/Users/leon/Library/Developer/Xcode/DerivedData/QPatch-gvmpfbziiefwslesfbaeoapqwxkb/Build/Products/Debug-iphoneos -mllvm -bcf -mllvm -bcf_prob=10 -include /Users/leon/Desktop/Code/ComCode/Patch/qpatch/QPatch/QTrade-Prefix.pch -c /Users/leon/Desktop/Code/ComCode/Patch/qpatch/QPatch/Patch/Patch/QTradeStart.m -o /Users/leon/Library/Developer/Xcode/DerivedData/QPatch-gvmpfbziiefwslesfbaeoapqwxkb/Build/Intermediates/QPatch.build/Debug-iphoneos/QPatch.build/Objects-normal/armv7/QTradeStart.o
0 clang-4.0 0x000000011031ec68 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40 1 clang-4.0 0x000000011031f216 SignalHandler(int) + 342 2 libsystem_platform.dylib 0x00007fffb8626b3a _sigtramp + 26 3 libsystem_platform.dylib 0x00007fd1c3899f02 _sigtramp + 187118562 4 clang-4.0 0x000000010feed472 llvm::FPPassManager::runOnFunction(llvm::Function&) + 530 5 clang-4.0 0x000000010feed673 llvm::FPPassManager::runOnModule(llvm::Module&) + 51 6 clang-4.0 0x000000010feedb0a llvm::legacy::PassManagerImpl::run(llvm::Module&) + 922 7 clang-4.0 0x00000001104ae929 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete >) + 10793
8 clang-4.0 0x000000011063378b clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 1019
9 clang-4.0 0x0000000110e30202 clang::ParseAST(clang::Sema&, bool, bool) + 466
10 clang-4.0 0x0000000110835693 clang::FrontendAction::Execute() + 67
11 clang-4.0 0x00000001107f73f8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1080
12 clang-4.0 0x0000000110875393 clang::ExecuteCompilerInvocation(clang::CompilerInstance ) + 5251
13 clang-4.0 0x000000010f15377b cc1_main(llvm::ArrayRef<char const>, char const, void*) + 1355
14 clang-4.0 0x000000010f15210a main + 10266
15 libdyld.dylib 0x00007fffb8417235 start + 1
16 libdyld.dylib 0x0000000000000092 start + 1203670622
Stack dump:
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-4.0: note: diagnostic msg: /var/folders/mv/srjjf32s64j5jcjj8tz79kdw0000gn/T/QTradeStart-e11669.m clang-4.0: note: diagnostic msg: /var/folders/mv/srjjf32s64j5jcjj8tz79kdw0000gn/T/QTradeStart-e11669.cache clang-4.0: note: diagnostic msg: /var/folders/mv/srjjf32s64j5jcjj8tz79kdw0000gn/T/QTradeStart-e11669.sh clang-4.0: note: diagnostic msg: /var/folders/mv/srjjf32s64j5jcjj8tz79kdw0000gn/T/QTradeStart-e11669.crash clang-4.0: note: diagnostic msg:
Command /Users/leon/Desktop/Code/GitCode/build/bin/clang failed with exit code 254