[PATCH v3 3/3] riscv: fix building compressed EFI image
Dmitry Antipov
dmantipov at yandex.ru
Mon Apr 13 02:22:02 PDT 2026
When building vmlinuz.efi with CONFIG_EFI_ZBOOT enabled,
'__lshrdi3()' is also needed to fix yet another link error:
riscv32-linux-gnu-ld: drivers/firmware/efi/libstub/lib-cmdline.stub.o: in function `__efistub_.L49':
__efistub_cmdline.c:(.init.text+0x202): undefined reference to `__efistub___lshrdi3'
And since riscv64 can have CONFIG_EFI_ZBOOT but doesn't need
these library routines, introduce CONFIG_EFI_ZBOOT_EXTRAS to
manage linking of lib-ashldi3.o lib-lshrdi3.o on riscv32 only.
Reviewed-and-tested-by: Charlie Jenkins <thecharlesjenkins at gmail.com>
Signed-off-by: Dmitry Antipov <dmantipov at yandex.ru>
---
v3: initial version to join the series
---
drivers/firmware/efi/Kconfig | 4 ++++
drivers/firmware/efi/libstub/Makefile | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig
index 29e0729299f5..55fb5a20aa25 100644
--- a/drivers/firmware/efi/Kconfig
+++ b/drivers/firmware/efi/Kconfig
@@ -85,6 +85,10 @@ config EFI_ZBOOT
provided that the loader implements the decompression algorithm.
(The compression algorithm used is described in the zboot header)
+config EFI_ZBOOT_EXTRAS
+ bool
+ default y if RISCV && 32BIT
+
config EFI_ARMSTUB_DTB_LOADER
bool "Enable the DTB loader"
depends on EFI_GENERIC_STUB && !RISCV && !LOONGARCH
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index e386ffd009b7..8f199b99d0f6 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -96,7 +96,8 @@ CFLAGS_zboot-decompress-gzip.o += -I$(srctree)/lib/zlib_inflate
zboot-obj-$(CONFIG_KERNEL_ZSTD) := zboot-decompress-zstd.o lib-xxhash.o
CFLAGS_zboot-decompress-zstd.o += -I$(srctree)/lib/zstd
-zboot-obj-$(CONFIG_RISCV) += lib-clz_ctz.o lib-ashldi3.o
+zboot-obj-extras-$(CONFIG_EFI_ZBOOT_EXTRAS) += lib-ashldi3.o lib-lshrdi3.o
+zboot-obj-$(CONFIG_RISCV) += lib-clz_ctz.o $(zboot-obj-extras-y)
lib-$(CONFIG_EFI_ZBOOT) += zboot.o $(zboot-obj-y)
lib-$(CONFIG_UNACCEPTED_MEMORY) += unaccepted_memory.o bitmap.o find.o
--
2.53.0
More information about the linux-riscv
mailing list