[kvm-unit-tests PATCH] Makefile: efi: preserve .dynstr section for LLVM objcopy compatibility

Colton Lewis coltonlewis at google.com
Thu Jul 16 10:33:15 PDT 2026


When building EFI binaries with llvm-objcopy, keeping sections with
'-j .dynamic -j .dynsym' without '-j .dynstr' fails with:

  llvm-objcopy: error: 'arm/spinlock-test.so': section '.dynstr'
  cannot be removed because it is referenced by the section '.dynamic'

Include '.dynstr' in the list of preserved sections across
arm/Makefile.common, riscv/Makefile, and x86/Makefile.common so that
EFI binaries can be built cleanly using llvm-objcopy.

Assisted-by: Gemini:gemini-next
Signed-off-by: Colton Lewis <coltonlewis at google.com>
---
 arm/Makefile.common | 2 +-
 riscv/Makefile      | 2 +-
 x86/Makefile.common | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arm/Makefile.common b/arm/Makefile.common
index a5d97bcf..550ec0a1 100644
--- a/arm/Makefile.common
+++ b/arm/Makefile.common
@@ -88,7 +88,7 @@ ifeq ($(CONFIG_EFI),y)
 	$(OBJCOPY) --strip-debug $^
 	$(OBJCOPY) --add-gnu-debuglink=$@.debug $^
 	$(OBJCOPY) \
-		-j .text -j .sdata -j .data -j .dynamic -j .dynsym \
+		-j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .dynstr \
 		-j .rel -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \
 		-j .reloc \
 		-O binary $^ $@
diff --git a/riscv/Makefile b/riscv/Makefile
index 64720c38..348a30a7 100644
--- a/riscv/Makefile
+++ b/riscv/Makefile
@@ -123,7 +123,7 @@ cflatobjs += lib/efi.o
 	$(OBJCOPY) --strip-debug $^
 	$(OBJCOPY) --add-gnu-debuglink=$@.debug $^
 	$(OBJCOPY) \
-		-j .text -j .sdata -j .data -j .rodata -j .dynamic -j .dynsym \
+		-j .text -j .sdata -j .data -j .rodata -j .dynamic -j .dynsym -j .dynstr \
 		-j .rel -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \
 		-j .reloc \
 		-O binary $^ $@
diff --git a/x86/Makefile.common b/x86/Makefile.common
index a251dd71..054e2391 100644
--- a/x86/Makefile.common
+++ b/x86/Makefile.common
@@ -58,7 +58,7 @@ ifeq ($(CONFIG_EFI),y)
 	$(OBJCOPY) --strip-debug $^
 	$(OBJCOPY) --add-gnu-debuglink=$@.debug $^
 	$(OBJCOPY) \
-		-j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
+		-j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .dynstr -j .rel \
 		-j .rela -j .reloc -S --target=$(FORMAT) $< $@
 	@chmod a-x $@
 else
-- 
2.55.0.229.g6434b31f56-goog




More information about the kvm-riscv mailing list