[PATCH v4 03/19] riscv: Make _text point to the start of the kernel image

Palmer Dabbelt palmer at dabbelt.com
Mon Nov 23 15:10:04 PST 2026


On Wed, 18 Nov 2026 10:21:09 PST (-0800), ardb+git at google.com wrote:
> 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 other architectures such as arm64, _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.
>
> Reviewed-by: Jason Gunthorpe <jgg at nvidia.com>
> 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

Reviewed-by: Palmer Dabbelt <palmer at dabbelt.com>
Acked-by: Palmer Dabbelt <palmer at dabbelt.com>



More information about the linux-riscv mailing list