[RFC PATCH v2 09/30] efi/libstub: Disable unwind tables in x86 and RISC-V EFI stubs

From: Ian Rogers

Date: Wed Nov 25 2026 - 01:19:39 EST


Pass -fno-unwind-tables and -fno-asynchronous-unwind-tables when
building x86 and RISC-V EFI libstub objects so enabling kernel-wide
asynchronous unwind tables under CONFIG_UNWINDER_DWARF_CFI does not emit
unwanted .eh_frame sections into the standalone EFI boot stub.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
drivers/firmware/efi/libstub/Makefile | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index bbab12b8eb4b..19c2822eb302 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -19,7 +19,8 @@ cflags-$(CONFIG_X86) := $(filter-out -mcmodel=kernel \
$(PADDING_CFLAGS), $(cflags-y))
cflags-$(CONFIG_X86_32) += -march=i386
cflags-$(CONFIG_X86_64) += -mcmodel=small
-cflags-$(CONFIG_X86) += -fPIC
+cflags-$(CONFIG_X86) += -fPIC -fno-unwind-tables \
+ -fno-asynchronous-unwind-tables
# Nothing enables IBT while the stub runs, so ENDBR would only take space.
cflags-$(CONFIG_X86) += $(call cc-option,-fcf-protection=none)

@@ -29,7 +30,9 @@ cflags-$(CONFIG_ARM) += -DEFI_HAVE_STRLEN -DEFI_HAVE_STRNLEN \
-DEFI_HAVE_MEMCHR -DEFI_HAVE_STRRCHR \
-DEFI_HAVE_STRCMP -fno-builtin -fpic \
$(call cc-option,-mno-single-pic-base)
-cflags-$(CONFIG_RISCV) += -fpic -DNO_ALTERNATIVE -mno-relax
+cflags-$(CONFIG_RISCV) += -fpic -DNO_ALTERNATIVE -mno-relax \
+ -fno-unwind-tables \
+ -fno-asynchronous-unwind-tables
cflags-$(CONFIG_LOONGARCH) += -fpie

cflags-$(CONFIG_EFI_PARAMS_FROM_FDT) += -I$(srctree)/scripts/dtc/libfdt
--
2.56.1.831.g720f3f5937-goog