[PATCH] Protection against stack-based memory corruption errors using SafeStack: Clang command line option and function attribute

Kostya Serebryany kcc at google.com
Mon Nov 3 15:18:15 PST 2014


================
Comment at: lib/Frontend/InitPreprocessor.cpp:830
@@ -829,1 +829,3 @@
+  else if (LangOpts.getStackProtector() == LangOptions::SSPSafeStack)
+    Builder.defineMacro("__SAFESTACK__", "4");
 
----------------
theraven wrote:
> It would be worth surveying a corpus of code and seeing what uses the __SSP defines.  We may find that it's worth defining some of them in SafeStack mode, as it may cause the same kind of breakage.
Note that AddressSanitizer does not define any preprocessor symbol. 
I tried to introduce __ADDRESS_SANITIZER__ but failed to convince the clang folks.
Instead, we use __has__feature(address_sanitizer), which is sadly incompatible with GCC's asan implementation, but works fine.

http://reviews.llvm.org/D6095






More information about the cfe-commits mailing list