Skip to content

Commit ca09bf4

Browse files
committed
scripts/kallsyms: exclude symbols generated by itself dynamically
Drop the symbols generated by scripts/kallsyms itself automatically instead of maintaining the symbol list manually. Pass the kallsyms object from the previous kallsyms step (if it exists) as the third parameter of scripts/mksysmap, which will weed out the generated symbols from the input to the next kallsyms step. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent c480204 commit ca09bf4

3 files changed

Lines changed: 13 additions & 20 deletions

File tree

scripts/kallsyms.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,6 @@ static bool is_ignored_symbol(const char *name, char type)
104104
{
105105
/* Symbol names that exactly match to the following are ignored.*/
106106
static const char * const ignored_symbols[] = {
107-
/*
108-
* Symbols which vary between passes. Passes 1 and 2 must have
109-
* identical symbol lists. The kallsyms_* symbols below are
110-
* only added after pass 1, they would be included in pass 2
111-
* when --all-symbols is specified so exclude them to get a
112-
* stable symbol list.
113-
*/
114-
"kallsyms_addresses",
115-
"kallsyms_offsets",
116-
"kallsyms_relative_base",
117-
"kallsyms_num_syms",
118-
"kallsyms_names",
119-
"kallsyms_markers",
120-
"kallsyms_token_table",
121-
"kallsyms_token_index",
122-
"kallsyms_seqs_of_names",
123107
/* Exclude linker generated symbols which vary between passes */
124108
"_SDA_BASE_", /* ppc */
125109
"_SDA2_BASE_", /* ppc */

scripts/link-vmlinux.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ kallsyms_step()
174174
kallsyms_S=${kallsyms_vmlinux}.S
175175

176176
vmlinux_link ${kallsyms_vmlinux} "${kallsymso_prev}" ${btf_vmlinux_bin_o}
177-
mksysmap ${kallsyms_vmlinux} ${kallsyms_vmlinux}.syms
177+
mksysmap ${kallsyms_vmlinux} ${kallsyms_vmlinux}.syms ${kallsymso_prev}
178178
kallsyms ${kallsyms_vmlinux}.syms ${kallsyms_S}
179179

180180
info AS ${kallsyms_S}
@@ -188,7 +188,7 @@ kallsyms_step()
188188
mksysmap()
189189
{
190190
info NM ${2}
191-
${CONFIG_SHELL} "${srctree}/scripts/mksysmap" ${1} ${2}
191+
${CONFIG_SHELL} "${srctree}/scripts/mksysmap" ${1} ${2} ${3}
192192
}
193193

194194
sorttable()
@@ -277,7 +277,7 @@ if is_enabled CONFIG_DEBUG_INFO_BTF && is_enabled CONFIG_BPF; then
277277
${RESOLVE_BTFIDS} vmlinux
278278
fi
279279

280-
mksysmap vmlinux System.map
280+
mksysmap vmlinux System.map ${kallsymso}
281281

282282
if is_enabled CONFIG_BUILDTIME_TABLE_SORT; then
283283
info SORTTAB vmlinux

scripts/mksysmap

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# tools to retrieve the actual addresses of symbols in the kernel.
55
#
66
# Usage
7-
# mksysmap vmlinux System.map
7+
# mksysmap vmlinux System.map [exclude]
88

99

1010
#####
@@ -52,4 +52,13 @@ ${NM} -n ${1} | sed >${2} -e "
5252
5353
# for LoongArch?
5454
/ L0$/d
55+
56+
# ---------------------------------------------------------------------------
57+
# Ignored kallsyms symbols
58+
#
59+
# If the 3rd parameter exists, symbols from it will be omitted from the output.
60+
# This makes kallsyms have the identical symbol lists in the step 1 and 2.
61+
# Without this, the step2 would get new symbols generated by scripts/kallsyms.c
62+
# when CONFIG_KALLSYMS_ALL is enabled. That might require one more pass.
63+
$(if [ $# -ge 3 ]; then ${NM} ${3} | sed -n '/ U /!s:.* \([^ ]*\)$:/ \1$/d:p'; fi)
5564
"

0 commit comments

Comments
 (0)