From d763c2308165d40db631bd123f0ddde830de3ffb Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 22 Nov 2014 08:49:34 +0000 Subject: 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 --- include/c.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/c.h') 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 */ -- cgit v1.2.3-55-g7522