fix/allsyms - #19593
Open
hitHuang wants to merge 4 commits into
Open
Conversation
hitHuang
requested review from
anchao,
cederom,
eren-terzioglu,
fdcavalcanti,
gustavonihei,
jerpelea,
lupyuen,
masayuki2009,
pussuw,
tmedicci,
xiaoxiang781216 and
yf13
as code owners
August 1, 2026 05:17
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
allsyms_findbyvalue()/%pS printed a bogus name/offset for addresses outside the real symbol table's coverage, due to the boundary sentinels being matchable as real symbols. Compute the high sentinel from the actual symbol range and treat a sentinel match as "not found". Signed-off-by: liang.huang <liang.huang@houmo.ai> Assisted-by: Claude Code:claude-sonnet-5
allsyms_lookup() derived a symbol's size from the physically next table entry, assuming address order. Under CONFIG_SYMTAB_ORDEREDBYNAME the table is sorted by name instead, producing a huge bogus size in %pS/backtrace output. Scan for the closest larger address instead of relying on table order. Signed-off-by: liang.huang <liang.huang@houmo.ai> Assisted-by: Claude Code:claude-sonnet-5
Several risc-v assembly labels are .global but untyped, so mkallsyms.py (which only collects STT_FUNC symbols) silently drops them from the ALLSYMS table, and backtraces/%pS print raw addresses instead of names. Add .type <name>, function to the affected labels, matching existing convention elsewhere in the tree. Signed-off-by: liang.huang <liang.huang@houmo.ai> Assisted-by: Claude Code:claude-sonnet-5
xiaoxiang781216
approved these changes
Aug 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CONFIG_ALLSYMSdoesn't even link underCONFIG_BUILD_PROTECTED/CONFIG_BUILD_KERNEL:g_allsyms/g_nallsymsonly exist in the kernel image, butsymtab_allsyms.creferencing them is built into user-modelibc.atoo. Once that's fixed and you actually try backtraces, three more bugs show up: user-mode addresses get matched against unrelated kernel symbols, symbol sizes are garbage underCONFIG_SYMTAB_ORDEREDBYNAME, and a bunch of assembly-only entry points (exception/boot code) never resolve to a name because they were never markedSTT_FUNC. This PR fixes all four.Impact
Touches
libs/libc/symtab/symtab_allsyms.cand a few risc-v assembly boot/exception files. No new Kconfig, no API changes, nothing changes unlessCONFIG_ALLSYMS=y.Testing
All of the below is
rv-virt:knshwithCONFIG_ALLSYMS,CONFIG_SYSTEM_DUMPSTACK,CONFIG_FRAME_POINTER, andCONFIG_SCHED_BACKTRACEturned on by hand, unless noted otherwise. Also checked onpnsh, and regression-testednshto make sure nothing else broke.Problem 0: link failure under BUILD_PROTECTED/BUILD_KERNEL
rv-virt:knsh:rv-virt:pnsh, same underlying problem:Problems 1-3: after fixing the link error, boots but backtraces are wrong
Before fixing problems 1-3:
Three problems here:
register_blockdriver-style output), which is worse than useless.nxsem_wait_uninterruptible+0x16/0xffffb9b0.Unknown+0x8020004a/0x80207d2e).Problem 1 doesn't really have a fix beyond "don't lie": there's no way to resolve a user-mode symbol from kernel context, so the right behavior is just falling back to the raw address instead of guessing:
After fixing problem 2, symbol sizes are correct:
After fixing problem 3, assembly-only symbols resolve correctly too (
__start,exception_common):Known follow-up (not fixed here)
g_symtabandg_allsymshave nothing to do with each other — different data, different generators — butsymtab_findbyname()/symtab_findbyvalue()only get compiled once, so both tables end up forced to share the same global ordering assumption (CONFIG_SYMTAB_ORDEREDBYNAME/CONFIG_SYMTAB_ORDEREDBYVALUE).