Skip to content

Commit 8959e39

Browse files
keesmasahir0y
authored andcommitted
kbuild: Parameterize kallsyms generation and correct reporting
When kallsyms generation happens, temporary vmlinux outputs are linked but the quiet make output didn't report it, giving the impression that the prior command is taking longer than expected. Instead, report the linking step explicitly. While at it, this consolidates the repeated "kallsyms generation step" into a single function and removes the existing copy/pasting. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent c7c0eec commit 8959e39

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

‎scripts/link-vmlinux.sh‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ modpost_link()
6060
# ${2} - output file
6161
vmlinux_link()
6262
{
63+
info LD ${2}
6364
local lds="${objtree}/${KBUILD_LDS}"
6465
local objects
6566

@@ -138,6 +139,18 @@ kallsyms()
138139
${CC} ${aflags} -c -o ${2} ${afile}
139140
}
140141

142+
# Perform one step in kallsyms generation, including temporary linking of
143+
# vmlinux.
144+
kallsyms_step()
145+
{
146+
kallsymso_prev=${kallsymso}
147+
kallsymso=.tmp_kallsyms${1}.o
148+
kallsyms_vmlinux=.tmp_vmlinux${1}
149+
150+
vmlinux_link "${kallsymso_prev}" ${kallsyms_vmlinux}
151+
kallsyms ${kallsyms_vmlinux} ${kallsymso}
152+
}
153+
141154
# Create map file with all symbols from ${1}
142155
# See mksymap for additional details
143156
mksysmap()
@@ -216,6 +229,7 @@ info MODINFO modules.builtin.modinfo
216229
${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo
217230

218231
kallsymso=""
232+
kallsymso_prev=""
219233
kallsyms_vmlinux=""
220234
if [ -n "${CONFIG_KALLSYMS}" ]; then
221235

@@ -242,32 +256,18 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
242256
# a) Verify that the System.map from vmlinux matches the map from
243257
# ${kallsymso}.
244258

245-
kallsymso=.tmp_kallsyms2.o
246-
kallsyms_vmlinux=.tmp_vmlinux2
247-
248-
# step 1
249-
vmlinux_link "" .tmp_vmlinux1
250-
kallsyms .tmp_vmlinux1 .tmp_kallsyms1.o
251-
252-
# step 2
253-
vmlinux_link .tmp_kallsyms1.o .tmp_vmlinux2
254-
kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o
259+
kallsyms_step 1
260+
kallsyms_step 2
255261

256262
# step 3
257-
size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" .tmp_kallsyms1.o)
258-
size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" .tmp_kallsyms2.o)
263+
size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso_prev})
264+
size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
259265

260266
if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
261-
kallsymso=.tmp_kallsyms3.o
262-
kallsyms_vmlinux=.tmp_vmlinux3
263-
264-
vmlinux_link .tmp_kallsyms2.o .tmp_vmlinux3
265-
266-
kallsyms .tmp_vmlinux3 .tmp_kallsyms3.o
267+
kallsyms_step 3
267268
fi
268269
fi
269270

270-
info LD vmlinux
271271
vmlinux_link "${kallsymso}" vmlinux
272272

273273
if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then

0 commit comments

Comments
 (0)