[PATCH 2/3] riscv: Make _text point to the start of the kernel image
Ard Biesheuvel
ardb+git at google.com
Wed Nov 11 08:43:48 PST 2026
From: Ard Biesheuvel <ardb at kernel.org>
On RISC-V, _text currently refers to the start of the .text output
section, which is placed after the image header (.head.text), and is
therefore equal to _stext. On most other architectures such, _text
refers to the start of the image, and is used as such by generic code,
e.g., to describe the kernel mapping in /proc/kcore and in the ELF
headers of the vmcore, and by the EFI stub.
Now that arch/riscv no longer uses _text to refer to the start of the
kernel code, move it to the start of the image so that it is equal to
_start, and the distinction between _text and _stext is the same as on
other architectures.
This also means that the image header is no longer omitted from the
/proc/kcore and vmcore kernel text mappings. Other users of _text, such
as kallsyms and ftrace, only use it as a reference point to calculate
relative offsets, and are not affected by this change.
Note that, as on arm64, _text will no longer appear in /proc/kallsyms
unless CONFIG_KALLSYMS_ALL=y, given that it now lives outside of the
[_stext, _etext) range. User space tools such as perf already fall back
to _stext in this case.
Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
---
arch/riscv/kernel/vmlinux.lds.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
index 1f4f8496941a..9849a3e4d102 100644
--- a/arch/riscv/kernel/vmlinux.lds.S
+++ b/arch/riscv/kernel/vmlinux.lds.S
@@ -28,11 +28,11 @@ SECTIONS
/* Beginning of code and text segment */
. = LOAD_OFFSET;
_start = .;
+ _text = .;
HEAD_TEXT_SECTION
. = ALIGN(PAGE_SIZE);
.text : {
- _text = .;
_stext = .;
TEXT_TEXT
SCHED_TEXT
--
2.56.0.611.g1030f0b940-goog
More information about the linux-riscv
mailing list