]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include/c: define UL_ASAN_BLACKLIST address_sanitizer function attribute
authorSami Kerola <kerolasa@iki.fi>
Sat, 22 Nov 2014 08:49:34 +0000 (08:49 +0000)
committerKarel Zak <kzak@redhat.com>
Fri, 19 Dec 2014 10:32:38 +0000 (11:32 +0100)
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>
include/c.h

index 068e2676a9c2989d87565ba5eec980fdd7eefc7d..a72e2641c4113a1752a0dba730950fdb9500623b 100644 (file)
@@ -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 */