Skip to content

Commit

Permalink
core/xfa: disable asan on llvm
Browse files Browse the repository at this point in the history
  • Loading branch information
Teufelchen1 committed Feb 15, 2023
1 parent fcf63cf commit 805aa42
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
14 changes: 14 additions & 0 deletions core/lib/include/compiler_hints.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ extern "C" {
#endif
#endif

/**
* @def NO_SANITIZE_ARRAY
* @brief Tell the compiler that this array should be ignored during sanitizing.
* @details In special cases, e.g. XFA, the address sanitizer might interfere
* in a way that breaks the application. Use this macro to disable
* address sanitizing for a given variable. Currently only utilised
* by llvm.
*/
#if defined(__llvm__) || defined(__clang__)
#define NO_SANITIZE_ARRAY __attribute__((no_sanitize("address")))
#else
#define NO_SANITIZE_ARRAY
#endif

/**
* @def UNREACHABLE()
* @brief Tell the compiler that this line of code cannot be reached.
Expand Down
10 changes: 6 additions & 4 deletions core/lib/include/xfa.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
*
* @internal
*/
#define _XFA(name, prio) __attribute__((used, section(".xfa." #name "." #prio)))
#define _XFA(name, prio) \
NO_SANITIZE_ARRAY \
__attribute__((used, section(".xfa." #name "." #prio)))

/**
* @brief helper macro for other XFA_* macros
*
* @internal
*/
#define _XFA_CONST(name, \
prio) __attribute__((used, \
section(".roxfa." #name "." #prio)))
#define _XFA_CONST(name, prio) \
NO_SANITIZE_ARRAY \
__attribute__((used, section(".roxfa." #name "." #prio)))

/**
* @brief Define a read-only cross-file array
Expand Down

0 comments on commit 805aa42

Please sign in to comment.