[PATCH v9 6/6] riscv: export symbols needed for riscv32 EFI stub
Charlie Jenkins
thecharlesjenkins at gmail.com
Wed Apr 8 22:00:18 PDT 2026
On Fri, Apr 03, 2026 at 01:33:38PM +0300, Dmitry Antipov wrote:
> Fix the following link error observed when building EFI-enabled
> kernel with CONFIG_EFI_STUB=y and CONFIG_EFI_GENERIC_STUB=y:
>
> riscv32-linux-gnu-ld: ./drivers/firmware/efi/libstub/lib-cmdline.stub.o: in function `__efistub_.L49':
> __efistub_cmdline.c:(.init.text+0x1f2): undefined reference to `__efistub___ashldi3'
> riscv32-linux-gnu-ld: __efistub_cmdline.c:(.init.text+0x202): undefined reference to `__efistub___lshrdi3'
>
> Note: compile (gcc 15.2.1 and clang 21.1.8) tested only.
I attempted to boot this on riscv32 in qemu with u-boot. I used
CONFIG_EFI_ZBOOT to generate vmlinux.efi. With this option enabled,
there is the same undefined reference errors with this patch applied.
I have not found a good way to resolve this issue, so I resorted to
copying the __lshrdi3() implementation over into
drivers/firmware/efi/libstub/riscv.c and that successfully booted with
EFI.
- Charlie
>
> Reported-by: kernel test robot <lkp at intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202603041925.KLKqpK6N-lkp@intel.com
> Suggested-by: Ard Biesheuvel <ardb at kernel.org>
> Signed-off-by: Dmitry Antipov <dmantipov at yandex.ru>
> ---
> v9: initial version to join the series
> ---
> arch/riscv/kernel/image-vars.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/arch/riscv/kernel/image-vars.h b/arch/riscv/kernel/image-vars.h
> index 3bd9d06a8b8f..888bb1ddf945 100644
> --- a/arch/riscv/kernel/image-vars.h
> +++ b/arch/riscv/kernel/image-vars.h
> @@ -32,6 +32,15 @@ __efistub___init_text_end = __init_text_end;
> __efistub_sysfb_primary_display = sysfb_primary_display;
> #endif
>
> +#ifdef CONFIG_CC_IS_GCC
> +/*
> + * Double-word integer shifts are used by the library code and so EFI stub as
> + * well. Not needed for clang and please let me know if anyone understands why.
> + */
> +PROVIDE(__efistub___lshrdi3 = __lshrdi3);
> +PROVIDE(__efistub___ashldi3 = __ashldi3);
> +#endif /* CONFIG_CC_IS_GCC */
> +
> #endif
>
> #endif /* __RISCV_KERNEL_IMAGE_VARS_H */
> --
> 2.53.0
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
>
More information about the linux-riscv
mailing list