[PATCH 24/27] x86: efi: Enable --gc-sections to drop unused code

Simon Glass sjg at chromium.org
Wed May 28 10:24:50 CEST 2025


Add --gc-sections to help reduce the size of the EFI app. Add a check
for undefined symbols too, since using these can hang or crash the app.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 arch/x86/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index ac1f1922b12..0deea05c15f 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -77,7 +77,7 @@ CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
 ifeq ($(CONFIG_EFI_APP),y)
 
 PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
-LDFLAGS_FINAL += -znocombreloc -shared
+LDFLAGS_FINAL += -znocombreloc -shared --gc-sections --no-undefined
 LDSCRIPT := $(LDSCRIPT_EFI)
 
 else
-- 
2.43.0



More information about the U-Boot mailing list