]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
kallsyms: Get rid of kallsyms relative base
authorArd Biesheuvel <ardb@kernel.org>
Fri, 16 Jan 2026 09:34:02 +0000 (10:34 +0100)
committerNathan Chancellor <nathan@kernel.org>
Thu, 22 Jan 2026 22:58:22 +0000 (15:58 -0700)
commita081b5789255d27b76cd2cbab85676b2a31dbde1
treeb4507fd88357c428978ba8a6cc572efab8258c59
parentff79d31eb536f6d87bcbc09287d54d5606bf6dbe
kallsyms: Get rid of kallsyms relative base

When the kallsyms relative base was introduced, per-CPU variable
references on x86_64 SMP were implemented as offsets into the respective
per-CPU region, rather than offsets relative to the location of the
variable's template in the kernel image, which is how other
architectures implement it.

This required kallsyms to reason about the difference between the two,
and the sign of the value in the kallsyms_offsets[] array was used to
distinguish them. This meant that negative offsets were not permitted
for ordinary variables, and so it was crucial that the relative base was
chosen such that all offsets were positive numbers.

This is no longer needed: instead, the offsets can simply be encoded as
values in the range -/+ 2 GiB, which is precisely what PC32 relocations
provide on most architectures. So it is possible to simplify the logic,
and just use _text as the anchor directly, and let the linker calculate
the final value based on the location of the entry itself.

Some architectures (nios2, extensa) do not support place-relative
relocations at all, but these are all 32-bit and non-relocatable, and so
there is no need for place-relative relocations in the first place, and
the actual symbol values can just be stored directly.

This makes all entries in the kallsyms_offsets[] array visible as
place-relative references in the ELF metadata, which will be important
when implementing ELF-based fg-kaslr.

Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://patch.msgid.link/20260116093359.2442297-6-ardb+git@google.com
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
kernel/kallsyms.c
kernel/kallsyms_internal.h
kernel/vmcore_info.c
scripts/kallsyms.c
scripts/link-vmlinux.sh
tools/perf/tests/vmlinux-kallsyms.c