diff options
| author | Lorenzo Stoakes (ARM) <ljs@kernel.org> | 2026-09-23 18:17:53 +0100 |
|---|---|---|
| committer | Nathan Chancellor <nathan@kernel.org> | 2026-09-26 00:16:34 +0100 |
| commit | 4719513c0fa2a39a2410448120a83cb1a416b194 (patch) | |
| tree | 6ae466c42f2d258c1627385d9eb81e064228ce8e /tools/lib/python | |
| parent | 83da9f3197e50d2e2c5b8b8d8358b6be6e867d7f (diff) | |
| download | linux-next-4719513c0fa2a39a2410448120a83cb1a416b194.tar.gz linux-next-4719513c0fa2a39a2410448120a83cb1a416b194.zip | |
sorttable: parse nm output correctly
sorttable reads a list of functions from vmlinux, provided by the output of
nm, with the -S flag specified providing function sizes.
It does so using fscanf(fp, "%16s %16s %c %*s\n", ...) reading address,
size, type (a single character) and name.
However, nm outputs no size for a symbol which has none, meaning that it
misinterprets these entries - interpreting the type character as the size,
and, if the name is a single character, ignores the newline and swallows
the address of the next entry.
Size-less single character names exist (e.g. the assemblers' loop counters
left over as local absolute symbols):
0000000000000001 a i
000000000000000f a i
0000000000000050 a j
0000000000000052 a t
000000000000009f a i
0000000000000200 a i
sorttable is looking for functions and these are not that, and with nm's
output sorted, it just so happens to be that what's swallowed is never a
function.
However the next commit in this series stops sorting nm's output, so this
bug can results in function names being lost.
Fix the issue by using '%*[^\n]' in fscanf() rather than '%*s' such that
the scan cannot move past the newline.
Then, compare the address and size fields (which are always padded to the
same width if output by nm) - if they differ, then this is a misread, so
simply discard the entry.
It's fine to discard these, as sorttable's raison d'être is to discover
whether a call site is contained within a function and an empty function
can't contain anything.
Assisted-by: LLM
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Link: https://patch.msgid.link/20260923-build-speedup-v4-4-73128809a4a4@kernel.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
