[Concept,07/15] riscv: Add EFI application build flags

Message ID 20260212001410.1919749-8-sjg@u-boot.org
State New
Headers
Series riscv: Add EFI-application support |

Commit Message

Simon Glass Feb. 12, 2026, 12:13 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Add the build machinery for RISC-V EFI applications in config.mk:

- OBJCOPYFLAGS_EFI for the EFI stub binary sections
- LDFLAGS_FINAL with -shared -Bsymbolic for the shared-object link
- LDSCRIPT pointing to the EFI app linker script
- Separate OBJCOPYFLAGS_EFI for the app, which uses a different
  set of sections since the linker script groups data contiguously

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 arch/riscv/config.mk | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
  

Patch

diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
index 123b5d24cca..1d98c015357 100644
--- a/arch/riscv/config.mk
+++ b/arch/riscv/config.mk
@@ -33,3 +33,20 @@  endif
 
 EFI_CRT0		:= crt0_riscv_efi.o
 EFI_RELOC		:= reloc_riscv_efi.o
+
+OBJCOPYFLAGS_EFI += -j .text -j .rodata -j .data -j .sdata -j .dynamic \
+	-j .dynsym -j .rela -j .reloc -j .got -j .got.plt \
+	-j __u_boot_list -j .embedded_dtb -O binary
+
+ifeq ($(CONFIG_EFI_APP),y)
+
+LDFLAGS_FINAL += -znocombreloc -shared -Bsymbolic --gc-sections
+LDSCRIPT := $(srctree)/arch/riscv/lib/elf_riscv64_efi_app.lds
+
+# The EFI app linker script places all data sections contiguously
+# between _data and _edata so the PE .data section covers them.
+OBJCOPYFLAGS_EFI := -j .text -j .rela.dyn \
+	-j .dynsym -j .dynstr -j .embedded_dtb -j .data \
+	-O binary
+
+endif