2016-09-07 120 views
3

我們使用以下代碼來確定編譯時是否爲clang和gcc指定了-sanitize = address。我們如何確定-sanitize = undefined是否已被指定?如何確定UBSAN是否使用clang或gcc進行了編譯?

bool isSanitized = false; 
#if defined(__has_feature) 
#if __has_feature(address_sanitizer) 
    isSanitized = true; 
#endif 
#elif defined(__SANITIZE_ADDRESS__) 
    isSanitized = true; 
#endif 
+0

你可能會檢查這個http://stackoverflow.com/questions/38719560/is-there-a-way-to-store-clang-compile-time-flags-in-the-output-binary – xhamr

+0

這並不是' t的工作方式與ASAN檢測相同。 –

回答

0

我建議你這個文件以峨山github上(GCC或Bugzilla的)這個錯誤(我們已經有阿三和贊定義是很有意義煮一個UBSan以及)。現在看起來你唯一的選擇是在Makefile中將定製的定義和-fsanitize-undefined一起傳遞。

相關問題