]> Git Repo - linux.git/commit
kallsyms: Avoid weak references for kallsyms symbols
authorArd Biesheuvel <[email protected]>
Mon, 15 Apr 2024 16:20:43 +0000 (18:20 +0200)
committerMasahiro Yamada <[email protected]>
Thu, 2 May 2024 10:48:26 +0000 (19:48 +0900)
commit951bcae6c5a0bfaa55b27c5f16178204988f0379
treebc40f7a42a32785eba057dd7128580e7c5a1c851
parentc3f7bed8fa141c02d715f856ba1a6a757b8c8db9
kallsyms: Avoid weak references for kallsyms symbols

kallsyms is a directory of all the symbols in the vmlinux binary, and so
creating it is 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, and instead, provide fallback
definitions in the linker script that are only emitted if an unsatisfied
reference exists.

While at it, drop the FRV specific annotation that these symbols reside
in .rodata - FRV is long gone.

Tested-by: Nick Desaulniers <[email protected]> # Boot
Reviewed-by: Nick Desaulniers <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Acked-by: Arnd Bergmann <[email protected]>
Link: https://lkml.kernel.org/r/20230504174320.3930345-1-ardb%40kernel.org
Signed-off-by: Ard Biesheuvel <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
include/asm-generic/vmlinux.lds.h
kernel/kallsyms.c
kernel/kallsyms_internal.h
This page took 0.077448 seconds and 4 git commands to generate.