]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tools/nolibc: support UBSAN on gcc
authorThomas Weißschuh <linux@weissschuh.net>
Wed, 8 Apr 2026 21:03:57 +0000 (23:03 +0200)
committerThomas Weißschuh <linux@weissschuh.net>
Thu, 9 Apr 2026 21:25:40 +0000 (23:25 +0200)
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@weissschuh.net>
Link: https://patch.msgid.link/20260408-nolibc-gcc-15-v1-2-330d0c40f894@weissschuh.net
tools/include/nolibc/compiler.h

index b1239344d894a6f446d2db5e4f4e0453f30003aa..b56570bf9f69e191a5833483859473afa4118d3c 100644 (file)
 #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