From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
Ard Biesheuvel <ardb@kernel.org>,
Masahiro Yamada <masahiroy@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nicolas@fjasle.eu>
Subject: [PATCH 1/3] kbuild: refactor variables in scripts/link-vmlinux.sh
Date: Wed, 22 May 2024 20:47:53 +0900 [thread overview]
Message-ID: <20240522114755.318238-2-masahiroy@kernel.org> (raw)
In-Reply-To: <20240522114755.318238-1-masahiroy@kernel.org>
Clean up the variables in scripts/link-vmlinux.sh
- Specify the extra objects directly in vmlinux_link()
- Move the AS rule to kallsyms()
- Set kallsymso and btf_vmlinux_bin_o where they are generated
- Remove unneeded variable, kallsymso_prev
No functional change intended.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/link-vmlinux.sh | 48 +++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 26 deletions(-)
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 46ce5d04dbeb..b16967d33f1c 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -45,7 +45,6 @@ info()
# Link of vmlinux
# ${1} - output file
-# ${2}, ${3}, ... - optional extra .o files
vmlinux_link()
{
local output=${1}
@@ -101,7 +100,7 @@ vmlinux_link()
${ld} ${ldflags} -o ${output} \
${wl}--whole-archive ${objs} ${wl}--no-whole-archive \
${wl}--start-group ${libs} ${wl}--end-group \
- $@ ${ldlibs}
+ ${kallsymso} ${btf_vmlinux_bin_o} ${ldlibs}
}
# generate .BTF typeinfo from DWARF debuginfo
@@ -142,9 +141,11 @@ gen_btf()
et_rel='\1\0'
fi
printf "${et_rel}" | dd of=${2} conv=notrunc bs=1 seek=16 status=none
+
+ btf_vmlinux_bin_o=${2}
}
-# Create ${2} .S file with all symbols from the ${1} object file
+# Create ${2}.o file with all symbols from the ${1} object file
kallsyms()
{
local kallsymopt;
@@ -165,27 +166,25 @@ kallsyms()
kallsymopt="${kallsymopt} --lto-clang"
fi
- info KSYMS ${2}
- scripts/kallsyms ${kallsymopt} ${1} > ${2}
+ info KSYMS "${2}.S"
+ scripts/kallsyms ${kallsymopt} "${1}" > "${2}.S"
+
+ info AS "${2}.o"
+ ${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS} \
+ ${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} -c -o "${2}.o" "${2}.S"
+
+ kallsymso=${2}.o
}
# Perform one step in kallsyms generation, including temporary linking of
# vmlinux.
kallsyms_step()
{
- kallsymso_prev=${kallsymso}
kallsyms_vmlinux=.tmp_vmlinux.kallsyms${1}
- kallsymso=${kallsyms_vmlinux}.o
- kallsyms_S=${kallsyms_vmlinux}.S
- vmlinux_link ${kallsyms_vmlinux} "${kallsymso_prev}" ${btf_vmlinux_bin_o}
- mksysmap ${kallsyms_vmlinux} ${kallsyms_vmlinux}.syms
- kallsyms ${kallsyms_vmlinux}.syms ${kallsyms_S}
-
- info AS ${kallsymso}
- ${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS} \
- ${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
- -c -o ${kallsymso} ${kallsyms_S}
+ vmlinux_link "${kallsyms_vmlinux}"
+ mksysmap "${kallsyms_vmlinux}" "${kallsyms_vmlinux}.syms"
+ kallsyms "${kallsyms_vmlinux}.syms" "${kallsyms_vmlinux}"
}
# Create map file with all symbols from ${1}
@@ -223,19 +222,17 @@ fi
${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init init/version-timestamp.o
-btf_vmlinux_bin_o=""
+kallsymso=
+btf_vmlinux_bin_o=
+
if is_enabled CONFIG_DEBUG_INFO_BTF; then
- btf_vmlinux_bin_o=.btf.vmlinux.bin.o
- if ! gen_btf .tmp_vmlinux.btf $btf_vmlinux_bin_o ; then
+ if ! gen_btf .tmp_vmlinux.btf .btf.vmlinux.bin.o ; then
echo >&2 "Failed to generate BTF for vmlinux"
echo >&2 "Try to disable CONFIG_DEBUG_INFO_BTF"
exit 1
fi
fi
-kallsymso=""
-kallsymso_prev=""
-kallsyms_vmlinux=""
if is_enabled CONFIG_KALLSYMS; then
# kallsyms support
@@ -262,10 +259,9 @@ if is_enabled CONFIG_KALLSYMS; then
# ${kallsymso}.
kallsyms_step 1
- kallsyms_step 2
+ size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
- # step 3
- size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso_prev})
+ kallsyms_step 2
size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
@@ -273,7 +269,7 @@ if is_enabled CONFIG_KALLSYMS; then
fi
fi
-vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o}
+vmlinux_link vmlinux
# fill in BTF IDs
if is_enabled CONFIG_DEBUG_INFO_BTF && is_enabled CONFIG_BPF; then
--
2.40.1
next prev parent reply other threads:[~2024-05-22 11:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 11:47 [PATCH 0/3] kbuild: remove PROVIDE() and refactor vmlinux_link steps Masahiro Yamada
2024-05-22 11:47 ` Masahiro Yamada [this message]
2024-05-22 11:47 ` [PATCH 2/3] kbuild: remove PROVIDE() for kallsyms symbols Masahiro Yamada
2024-05-23 9:31 ` Ard Biesheuvel
2024-05-25 16:43 ` Masahiro Yamada
2024-05-22 11:47 ` [PATCH 3/3] kbuild: merge temp vmlinux for CONFIG_DEBUG_INFO_BTF and CONFIG_KALLSYMS Masahiro Yamada
2024-05-30 21:17 ` Andrii Nakryiko
2024-05-28 9:42 ` [PATCH 0/3] kbuild: remove PROVIDE() and refactor vmlinux_link steps Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240522114755.318238-2-masahiroy@kernel.org \
--to=masahiroy@kernel.org \
--cc=ardb@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=nicolas@fjasle.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox