[PATCH 2/3] tools/nolibc: support UBSAN on gcc
From: Thomas Weißschuh
Date: Wed Apr 08 2026 - 17:04:23 EST
The UBSAN implementation in gcc requires a slightly different function
attribute to skip instrumentation.
Extend __nolibc_no_sanitize_undefined to also handle gcc.
Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
tools/include/nolibc/compiler.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h
index b1239344d894..b56570bf9f69 100644
--- a/tools/include/nolibc/compiler.h
+++ b/tools/include/nolibc/compiler.h
@@ -81,7 +81,11 @@
#define _NOLIBC_OPTIMIZER_HIDE_VAR(var) __asm__ ("" : "+r" (var))
#if __nolibc_has_feature(undefined_behavior_sanitizer)
-# define __nolibc_no_sanitize_undefined __attribute__((no_sanitize("function")))
+# if defined(__clang__)
+# define __nolibc_no_sanitize_undefined __attribute__((no_sanitize("function")))
+# else
+# define __nolibc_no_sanitize_undefined __attribute__((no_sanitize_undefined))
+# endif
#else
# define __nolibc_no_sanitize_undefined
#endif
--
2.53.0