[PATCH 08/27] efi/libstub: Drop .discard.addressable from the stub objects

From: Josh Poimboeuf

Date: Fri Aug 28 2026 - 00:53:50 EST


On arm64, riscv and loongarch, the EFI stub objects are objcopy'd with
--prefix-alloc-sections=.init, which renames every allocatable section.

The .discard.addressable section is allocatable, so if
STACK_FRAME_NON_STANDARD() and __ADDRESSABLE() are used, the section
gets renamed and never discarded:

ld: warning: orphan section `.init.discard.addressable' from `vmlinux.o' being placed in section `.init.discard.addressable'

In preparation for using STACK_FRAME_NON_STANDARD() in libstub code,
remove the section during objcopy.

Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
drivers/firmware/efi/libstub/Makefile | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index 77a2b2d74f3f6..1344d08b420a2 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -155,6 +155,10 @@ STUBCOPY_FLAGS-$(CONFIG_LOONGARCH) += --prefix-alloc-sections=.init \
--prefix-symbols=__efistub_
STUBCOPY_RELOC-$(CONFIG_LOONGARCH) := R_LARCH_MARK_LA

+# Drop the section created by __ADDRESSABLE() so it doesn't get prefixed.
+# Its job is already done.
+STUBCOPY_FLAGS-y += --remove-section=.discard.addressable
+
$(obj)/%.stub.o: $(obj)/%.o FORCE
$(call if_changed,stubcopy)

--
2.55.0