tools/nolibc: support UBSAN on gcc

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
master
Thomas Weißschuh 2026-04-08 23:03:57 +02:00
parent 08ab958072
commit 3495279d05
1 changed files with 5 additions and 1 deletions

View File

@ -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