[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202108181940.896CA4311@keescook>
Date: Wed, 18 Aug 2021 19:42:18 -0700
From: Kees Cook <keescook@...omium.org>
To: Masahiro Yamada <masahiroy@...nel.org>
Cc: linux-kbuild@...r.kernel.org,
Sami Tolvanen <samitolvanen@...gle.com>,
linux-kernel@...r.kernel.org,
Michal Marek <michal.lkml@...kovi.net>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
clang-built-linux@...glegroups.com
Subject: Re: [PATCH 06/13] kbuild: merge vmlinux_link() between the ordinary
link and Clang LTO
On Thu, Aug 19, 2021 at 09:57:37AM +0900, Masahiro Yamada wrote:
> When Clang LTO is enabled, vmlinux_link() reuses vmlinux.o instead of
> linking ${KBUILD_VMLINUX_OBJS} and ${KBUILD_VMLINUX_LIBS} again.
>
> That is the only difference here, so merge the similar code.
Oh excellent! I had tried to get this merged before and was not happy
with anything I constructed. This is much cleaner. Nice! (I think I
didn't realize there could be an empty --start-group/--end-group with
no side-effects.)
Reviewed-by: Kees Cook <keescook@...omium.org>
-Kees
>
> Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
> ---
>
> scripts/link-vmlinux.sh | 30 ++++++++++++++----------------
> 1 file changed, 14 insertions(+), 16 deletions(-)
>
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index 36ef7b37fc5d..a6c4d0bce3ba 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -154,12 +154,23 @@ vmlinux_link()
> local objects
> local strip_debug
> local map_option
> + local objs
> + local libs
>
> info LD ${output}
>
> # skip output file argument
> shift
>
> + if [ -n "${CONFIG_LTO_CLANG}" ]; then
> + # Use vmlinux.o instead of performing the slow LTO link again.
> + objs=vmlinux.o
> + libs=
> + else
> + objs="${KBUILD_VMLINUX_OBJS}"
> + libs="${KBUILD_VMLINUX_LIBS}"
> + fi
> +
> # The kallsyms linking does not need debug symbols included.
> if [ "$output" != "${output#.tmp_vmlinux.kallsyms}" ] ; then
> strip_debug=-Wl,--strip-debug
> @@ -170,22 +181,9 @@ vmlinux_link()
> fi
>
> if [ "${SRCARCH}" != "um" ]; then
> - if [ -n "${CONFIG_LTO_CLANG}" ]; then
> - # Use vmlinux.o instead of performing the slow LTO
> - # link again.
> - objects="--whole-archive \
> - vmlinux.o \
> - --no-whole-archive \
> - ${@}"
> - else
> - objects="--whole-archive \
> - ${KBUILD_VMLINUX_OBJS} \
> - --no-whole-archive \
> - --start-group \
> - ${KBUILD_VMLINUX_LIBS} \
> - --end-group \
> - ${@}"
> - fi
> + objects="--whole-archive ${objs} --no-whole-archive \
> + --start-group ${libs} --end-group \
> + $@"
>
> ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \
> ${strip_debug#-Wl,} \
> --
> 2.30.2
>
--
Kees Cook
Powered by blists - more mailing lists