另外你用的是原版的clang吗
对,原版(Xcode10)和Hikari都一样,同样的错误
我这里原版clang没遇到这个问题啊:
clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk 123.m -fobjc-arc
123.m:2:17: warning: cannot find interface declaration for 'OBDemo'
@implementation OBDemo
^
123.m:8:67: warning: values of type 'NSInteger' should not be used as format
arguments; add an explicit cast to 'long' instead [-Wformat]
NSString *str = [NSString stringWithFormat:@"Hello -> %d",i];
~~ ^
%ld (long)
123.m:12:17: warning: incomplete format specifier [-Wformat]
NSLog(@"%",array);
^
123.m:20:17: warning: values of type 'NSUInteger' should not be used as format
arguments; add an explicit cast to 'unsigned long' instead [-Wformat]
NSLog(@"%d",p.length);
~~ ^~~~~~~~
%lu (unsigned long)
123.m:2:17: warning: class 'OBDemo' defined without specifying a base class
[-Wobjc-root-class]
@implementation OBDemo
^
123.m:2:23: note: add a super class to fix this problem
@implementation OBDemo
^
: NSObject
5 warnings generated.
Undefined symbols for architecture arm64:
"start", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
λ : >>> clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk 123.m -fobjc-arc -S -emit-llvm
123.m:2:17: warning: cannot find interface declaration for 'OBDemo'
@implementation OBDemo
^
123.m:8:67: warning: values of type 'NSInteger' should not be used as format
arguments; add an explicit cast to 'long' instead [-Wformat]
NSString *str = [NSString stringWithFormat:@"Hello -> %d",i];
~~ ^
%ld (long)
123.m:12:17: warning: incomplete format specifier [-Wformat]
NSLog(@"%",array);
^
123.m:20:17: warning: values of type 'NSUInteger' should not be used as format
arguments; add an explicit cast to 'unsigned long' instead [-Wformat]
NSLog(@"%d",p.length);
~~ ^~~~~~~~
%lu (unsigned long)
123.m:2:17: warning: class 'OBDemo' defined without specifying a base class
[-Wobjc-root-class]
@implementation OBDemo
^
123.m:2:23: note: add a super class to fix this problem
@implementation OBDemo
^
: NSObject
5 warnings generated.
naville @ navilledeMacBook-Pro in ~/Development/HikariRelease
λ : >>> bin/llvm-as 123.ll
naville @ navilledeMacBook-Pro in ~/Development/HikariRelease
λ : >>> bin/llvm-nm 123.bc
---------------- t +[OBDemo P1]
---------------- t +[OBDemo myName]
U _NSLog
U _OBJC_CLASS_$_NSArray
U _OBJC_CLASS_$_NSString
---------------- D _OBJC_CLASS_$_OBDemo
---------------- D _OBJC_METACLASS_$_OBDemo
U ___CFConstantStringClassReference
U __objc_empty_cache
U _objc_msgSend
U _objc_retain
U _objc_retainAutoreleasedReturnValue
U _objc_storeStrong
我的意思是,你不混淆用原版clang编译有这个问题吗,就同样步骤,但是不走opt
我重新试了一次
clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -fobjc-arc -c OBDemo.bc -o OBDemo.o
warning: overriding the module target triple with arm64-apple-ios5.0.0 [-Woverride-module]
1 warning generated.
Sc:~ qaq$ ar -crs arm64.a OBDemo.o
Sc:~ qaq$ ranlib arm64.a
结果打包成.a 拖进工程还是报错
Undefined symbols for architecture arm64:
"_clang.arc.use", referenced from:
+[OBDemo myName] in arm64.a(OBDemo.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
nm命令出来看了,应该是没有混淆的!
---------------- t +[OBDemo P1]
---------------- t +[OBDemo myName]
U _NSLog
U _OBJC_CLASS_$_NSArray
U _OBJC_CLASS_$_NSObject
U _OBJC_CLASS_$_NSString
---------------- D _OBJC_CLASS_$_OBDemo
U _OBJC_METACLASS_$_NSObject
---------------- D _OBJC_METACLASS_$_OBDemo
U ___CFConstantStringClassReference
U __objc_empty_cache
U _clang.arc.use
U _objc_msgSend
U _objc_release
U _objc_retainAutoreleasedReturnValue
hmmmm我没法复现你的问题啊
奇怪的是我把源码中语法糖(@[str2])删掉之后就正常编译了!
啊这就跟我观察到的IR的问题解释通了,我研究一下上上流问问
之前看Hikari的原帖我看到有人反馈过,是环境的问题.我刚刚换了台电脑…一切正常 玄学呀~
多次尝试后补充: xcodeproj版本太老导致的报错,新建一个工程放入混淆之后的库一切正常,感谢张总的指导了~
并不是。看起来只是前端的锅,我拿llvm的复现了下好像确实有问题,我到mailing list上问了还没人回我
是的,新旧xcodeproj工程默认引用了静态库,新工程没有引用,所以能正常编译 看来还是我高兴太早了
这个问题后来解决了没有?
用那个新的工具啊
大佬6666 之前的问题我解决了,只需要把编译条件的Optimization Level设置为None就可以了~
按照这个步骤在最后编译bc到excutable file时报错
bogon:demo appnest$ clang obf.bc -arch arm64 -o demo2
warning: overriding the module target triple with arm64-apple-macosx10.14.0 [-Woverride-module]
fatal error: error in backend: Cannot select: intrinsic %llvm.objc.clang.arc.use
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: aarch64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to http://developer.apple.com/bugreporter/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
bogon:demo appnest$
我对xar解出的bc分别做编译
有的可以成功
bogon:1 appnest$ /Library/Developer/Toolchains/光.xctoolchain/usr/bin/clang -cc1 -triple arm64 -emit-obj -disable-llvm-passes -mllvm -enable-acdobf -mllvm -bcf_prob=100 01 -o 01.o -x ir
warning: overriding the module target triple with arm64
1 warning generated.
有些会失败报一样的错误
bogon:1 appnest$ /Library/Developer/Toolchains/光.xctoolchain/usr/bin/clang -cc1 -triple arm64 -emit-obj -disable-llvm-passes -mllvm -enable-acdobf -mllvm -bcf_prob=100 02 -o 02.o -x ir
warning: overriding the module target triple with arm64
fatal error: error in backend: Cannot select: intrinsic %llvm.objc.clang.arc.use
您好,请问用什么工具可以把.xcarchive文件中的.bc提取出来加以混淆。另外,.bc文件应该是在mach-o文件中提取对吧。
谢谢。
想问下,大佬。ollvm可以做到对静态库(bitcode)文件的混淆加固吗?
我在执行:
lang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs -fobjc-arc -c .bc -o xxx.o
时报错, **error:** **Invalid record** 1 error generated.
。有什么方式解决吗?拜谢!