[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNARGZZC=5Pcy8qBpp1E94hRHHHdUu7KxVudH1iT-yugs=g@mail.gmail.com>
Date: Tue, 23 Apr 2024 01:02:42 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: Ard Biesheuvel <ardb+git@...gle.com>
Cc: linux-kernel@...r.kernel.org, Ard Biesheuvel <ardb@...nel.org>,
linux-kbuild@...r.kernel.org, Nick Desaulniers <ndesaulniers@...gle.com>,
Kees Cook <keescook@...omium.org>, Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH v5] kallsyms: Avoid weak references for kallsyms symbols
On Sat, Apr 20, 2024 at 11:53 PM Ard Biesheuvel <ardb+git@...gle.com> wrote:
>
> From: Ard Biesheuvel <ardb@...nel.org>
>
> kallsyms is a directory of all the symbols in the vmlinux binary, and so
> creating it poses somewhat of a chicken-and-egg problem, as its non-zero
> size affects the layout of the binary, and therefore the values of the
> symbols.
>
> For this reason, the kernel is linked more than once, and the first pass
> does not include any kallsyms data at all. For the linker to accept
> this, the symbol declarations describing the kallsyms metadata are
> emitted as having weak linkage, so they can remain unsatisfied. During
> the subsequent passes, the weak references are satisfied by the kallsyms
> metadata that was constructed based on information gathered from the
> preceding passes.
>
> Weak references lead to somewhat worse codegen, because taking their
> address may need to produce NULL (if the reference was unsatisfied), and
> this is not usually supported by RIP or PC relative symbol references.
>
> Given that these references are ultimately always satisfied in the final
> link, let's drop the weak annotation on the declarations, and instead,
> provide fallback definitions with weak linkage. This informs the
> compiler that ultimately, the reference will always be satisfied.
>
> While at it, drop the FRV specific annotation that these symbols reside
> in .rodata - FRV is long gone.
>
> Cc: Masahiro Yamada <masahiroy@...nel.org>
> Cc: linux-kbuild@...r.kernel.org
> Acked-by: Nick Desaulniers <ndesaulniers@...gle.com>
> Acked-by: Kees Cook <keescook@...omium.org>
> Acked-by: Arnd Bergmann <arnd@...db.de>
> Link: https://lore.kernel.org/all/20240415075837.2349766-5-ardb+git@google.com
> Signed-off-by: Ard Biesheuvel <ardb@...nel.org>
> ---
> v5: - avoid PROVIDE() in the linker script, use weak definitions instead
> - drop tested-by, replace reviewed-by with acked-by
>
Applied to linux-kbuild. Thanks.
--
Best Regards
Masahiro Yamada
Powered by blists - more mailing lists