Address-Sanitizer https://code.google.com/p/address-sanitizer/wiki/AddressSanitizer是否有人在iOS上使用Address-Sanitizer(称为asan或-fsanitize = address)?
我已经编译了我自己的llvm(很直接的编译),因为apple的llvm不支持这个函数。
我已经测试了mac命令行程序的clang,它的工作原理(但没有显示源代码行)。
适用于iOS,仍有一些问题:
- 编译模拟器版本:预编译头报错:
In file included from /Users/fluke/Documents/projects/tmp/testAsanNoARC/testAsanNoARC/testAsanNoARC-Prefix.pch:12: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:9: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:53:24: error: 'UIAccelerometer' is unavailable: not available on OS X - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration NS_DEPRECATED_IOS(2_0, 5_0); ^ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:33:12: note: declaration has been explicitly marked unavailable here @interface UIAccelerometer : NSObject { ^ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:53:71: error: 'UIAcceleration' is unavailable: not available on OS X - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration NS_DEPRECATED_IOS(2_0, 5_0); ...
- 编译器版本,它报告缺乏libarc(但实际上我不启用ARC)
ld: file not found: /Users/fluke/Documents/tools/asan/Debug+Asserts/lib/arc/libarclite_iphoneos.a clang: error: linker command failed with exit code 1 (use -v to see invocation)
- 所以我尝试使用它作为一个单独的库 - 只是新的lib目标和使用我自己的铛,而主要目标仍然使用苹果的llvm。程序编译(可能需要链接到构建的llvm中的asan dylib),但不起作用,因为我们需要在我们的程序入口之前加载。
谁有这样做的经验?