Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 04b8cb0

Browse files
committed
kbuild: avoid unneeded kallsyms step 3
Since commit 951bcae ("kallsyms: Avoid weak references for kallsyms symbols"), the kallsyms step 3 always occurs. You can compare the build logs. [Before 951bcae] $ git checkout 951bcae^ $ make defconfig all [ snip ] LD .tmp_vmlinux.kallsyms1 NM .tmp_vmlinux.kallsyms1.syms KSYMS .tmp_vmlinux.kallsyms1.S AS .tmp_vmlinux.kallsyms1.S LD .tmp_vmlinux.kallsyms2 NM .tmp_vmlinux.kallsyms2.syms KSYMS .tmp_vmlinux.kallsyms2.S AS .tmp_vmlinux.kallsyms2.S LD vmlinux [After 951bcae] $ git checkout 951bcae $ make defconfig all [ snip ] LD .tmp_vmlinux.kallsyms1 NM .tmp_vmlinux.kallsyms1.syms KSYMS .tmp_vmlinux.kallsyms1.S AS .tmp_vmlinux.kallsyms1.S LD .tmp_vmlinux.kallsyms2 NM .tmp_vmlinux.kallsyms2.syms KSYMS .tmp_vmlinux.kallsyms2.S AS .tmp_vmlinux.kallsyms2.S LD .tmp_vmlinux.kallsyms3 # should not happen NM .tmp_vmlinux.kallsyms3.syms # should not happen KSYMS .tmp_vmlinux.kallsyms3.S # should not happen AS .tmp_vmlinux.kallsyms3.S # should not happen LD vmlinux The resulting vmlinux is correct, but it always requires an additional linking step. The symbols produced by kallsyms are excluded from kallsyms itself because they were previously missing in step 1. With those symbols excluded, the symbol lists matched between step 1 and step 2, eliminating the need for step 3. Now, this has a negative effect. Since 951bcae, the PROVIDE() directives provide the fallback definitions, which are not trimmed from the sysbol list in step 1 because ${kallsymso_prev} is empty at this point. In step 2, ${kallsymso_prev} is set, and the kallsyms_* symbols are trimmed from the symbol list. Due to the table size difference between step 1 and step 2 (the former is larger due to the presence of kallsyms_*), step 3 is triggered. Now that the kallsyms_* symbols are always linked, let's stop omitting them from kallsyms. This avoids unnecessary step 3. Fixes: 951bcae ("kallsyms: Avoid weak references for kallsyms symbols") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 659bbf7 commit 04b8cb0

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

scripts/link-vmlinux.sh

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

181181
vmlinux_link ${kallsyms_vmlinux} "${kallsymso_prev}" ${btf_vmlinux_bin_o}
182-
mksysmap ${kallsyms_vmlinux} ${kallsyms_vmlinux}.syms ${kallsymso_prev}
182+
mksysmap ${kallsyms_vmlinux} ${kallsyms_vmlinux}.syms
183183
kallsyms ${kallsyms_vmlinux}.syms ${kallsyms_S}
184184

185185
info AS ${kallsyms_S}
@@ -193,7 +193,7 @@ kallsyms_step()
193193
mksysmap()
194194
{
195195
info NM ${2}
196-
${CONFIG_SHELL} "${srctree}/scripts/mksysmap" ${1} ${2} ${3}
196+
${CONFIG_SHELL} "${srctree}/scripts/mksysmap" ${1} ${2}
197197
}
198198

199199
sorttable()
@@ -282,7 +282,7 @@ if is_enabled CONFIG_DEBUG_INFO_BTF && is_enabled CONFIG_BPF; then
282282
${RESOLVE_BTFIDS} vmlinux
283283
fi
284284

285-
mksysmap vmlinux System.map ${kallsymso}
285+
mksysmap vmlinux System.map
286286

287287
if is_enabled CONFIG_BUILDTIME_TABLE_SORT; then
288288
info SORTTAB vmlinux

scripts/mksysmap

Lines changed: 1 addition & 10 deletions
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 [exclude]
7+
# mksysmap vmlinux System.map
88

99

1010
#####
@@ -92,13 +92,4 @@ ${NM} -n ${1} | sed >${2} -e "
9292
# ppc stub
9393
/\.long_branch\./d
9494
/\.plt_branch\./d
95-
96-
# ---------------------------------------------------------------------------
97-
# Ignored kallsyms symbols
98-
#
99-
# If the 3rd parameter exists, symbols from it will be omitted from the output.
100-
# This makes kallsyms have the identical symbol lists in the step 1 and 2.
101-
# Without this, the step2 would get new symbols generated by scripts/kallsyms.c
102-
# when CONFIG_KALLSYMS_ALL is enabled. That might require one more pass.
103-
$(if [ $# -ge 3 ]; then ${NM} ${3} | sed -n '/ U /!s:.* \([^ ]*\)$:/ \1$/d:p'; fi)
10495
"

0 commit comments

Comments
 (0)