mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:44:45 +01:00
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>
18 lines
469 B
C
18 lines
469 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#ifndef LINUX_KALLSYMS_INTERNAL_H_
|
|
#define LINUX_KALLSYMS_INTERNAL_H_
|
|
|
|
#include <linux/types.h>
|
|
|
|
extern const int kallsyms_offsets[];
|
|
extern const u8 kallsyms_names[];
|
|
|
|
extern const unsigned int kallsyms_num_syms;
|
|
|
|
extern const char kallsyms_token_table[];
|
|
extern const u16 kallsyms_token_index[];
|
|
|
|
extern const unsigned int kallsyms_markers[];
|
|
extern const u8 kallsyms_seqs_of_names[];
|
|
|
|
#endif // LINUX_KALLSYMS_INTERNAL_H_
|