summaryrefslogtreecommitdiffstats
path: root/include/c.h
diff options
context:
space:
mode:
authorSami Kerola2014-11-22 09:49:34 +0100
committerKarel Zak2014-12-19 11:32:38 +0100
commitd763c2308165d40db631bd123f0ddde830de3ffb (patch)
tree7ee20df5b1e99435fe3a896c1fe839e96d548768 /include/c.h
parentstrutils: fix unsigned integer overflows [AddressSanitizer] (diff)
downloadkernel-qcow2-util-linux-d763c2308165d40db631bd123f0ddde830de3ffb.tar.gz
kernel-qcow2-util-linux-d763c2308165d40db631bd123f0ddde830de3ffb.tar.xz
kernel-qcow2-util-linux-d763c2308165d40db631bd123f0ddde830de3ffb.zip
include/c: define UL_ASAN_BLACKLIST address_sanitizer function attribute
The UL_ASAN_BLACKLIST allows AddressSanitizer to be switched off for functions that cannot be checked. Reference: http://dxr.mozilla.org/mozilla-central/source/mfbt/Attributes.h Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'include/c.h')
-rw-r--r--include/c.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/c.h b/include/c.h
index 068e2676a..a72e2641c 100644
--- a/include/c.h
+++ b/include/c.h
@@ -321,4 +321,21 @@ static inline int xusleep(useconds_t usec)
#define stringify_value(s) stringify(s)
#define stringify(s) #s
+/*
+ * UL_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time
+ * instrumentation shipped with Clang and GCC) to not instrument the
+ * annotated function. Furthermore, it will prevent the compiler from
+ * inlining the function because inlining currently breaks the blacklisting
+ * mechanism of AddressSanitizer.
+ */
+#if defined(__has_feature)
+# if __has_feature(address_sanitizer)
+# define UL_ASAN_BLACKLIST __attribute__((noinline)) __attribute__((no_sanitize_memory)) __attribute__((no_sanitize_address))
+# else
+# define UL_ASAN_BLACKLIST /* nothing */
+# endif
+#else
+# define UL_ASAN_BLACKLIST /* nothing */
+#endif
+
#endif /* UTIL_LINUX_C_H */