libs/libc/symtab: fix g_allsyms link failure in BUILD_PROTECTED/KERNEL

g_allsyms/g_nallsyms only exist in the kernel image, but symtab_allsyms.c
is unconditionally built into libc.a, so user-mode code under
CONFIG_BUILD_PROTECTED/CONFIG_BUILD_KERNEL fails to link.

Guard the affected code so user-mode libc.a no longer references these
kernel-only symbols.

Signed-off-by: liang.huang <liang.huang@houmo.ai>
Assisted-by: Claude Code:claude-sonnet-5
This commit is contained in:
liang.huang 2026-07-25 10:54:17 +08:00
parent 69249fc9e6
commit 1393567e31

View file

@ -31,6 +31,8 @@
* Public Data
****************************************************************************/
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
extern const struct symtab_s g_allsyms[];
extern const int g_nallsyms;
@ -115,3 +117,21 @@ FAR const struct symtab_s *allsyms_findbyvalue(FAR void *value,
{
return allsyms_lookup(NULL, value, size);
}
#else
FAR const struct symtab_s *allsyms_findbyname(FAR const char *name,
FAR size_t *size)
{
*size = 0;
return NULL;
}
FAR const struct symtab_s *allsyms_findbyvalue(FAR void *value,
FAR size_t *size)
{
*size = 0;
return NULL;
}
#endif /* CONFIG_BUILD_FLAT || __KERNEL__ */