mm/kasan: fix build fail when CONFIG_MM_KASAN_GLOBAL and CONFIG_BUILD_KERNEL on

When CONFIG_MM_KASAN_GLOBAL is enabled, hook.c is also linked into
libmm.a. However, g_global_region (defined in global.c) is only
injected into the nuttx ELF by kasan_global.py — it does not process
the app binary. This causes undefined symbol errors when linking an
app against libmm.a.

Guard the inclusion of global.c with __KERNEL__ so that only kernel
builds pull in the global KASAN region, while app builds fall back
to the no-op stub.

Signed-off-by: leisiji <2265215145@qq.com>
This commit is contained in:
leisiji 2026-06-09 07:55:44 +08:00 committed by Mateusz Szafoni
parent 51d0848b74
commit 7253e70659

View file

@ -31,7 +31,7 @@
#include <stdint.h>
#include <stdio.h>
#ifdef CONFIG_MM_KASAN_GLOBAL
#if defined(CONFIG_MM_KASAN_GLOBAL) && defined(__KERNEL__)
# include "global.c"
#else
# define kasan_global_is_poisoned(addr, size) false