Skip to contentSkip to conversation

efi/libstub: zboot: Round up image size to section alignment

PATCH New Ard Biesheuvel 1 participant 1 message Oct 28 EFI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi/libstub: zboot: Round up image size to section alignment

From: Ard Biesheuvel <[email protected]>

Oliver reports that some arm64 EFI boot images have a SizeOfImage field in the PE header that is set to a value that is not a round multiple of the image's section alignment, which violates the PE/COFF spec.

This turns out to be a problem in the zboot linker script, and so it affects compressed EFI zboot images for all architectures, not only arm64. Uncompressed arm64 images built with an EFI stub are fine, as those are rounded up to 64k already.

So fix this by bumping the zboot _end marker to the next 4k boundary .

---
 drivers/firmware/efi/libstub/zboot.lds | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/libstub/zboot.lds +1 -1
index 367907eb7d86..a785c0123749 100644
@@ -45,7 +45,7 @@ SECTIONS
 
 	.bss : {
 		*(.bss* .init.bss*)
-		_end = ALIGN(512);
+		_end = ALIGN(4096);
 		. = _end;
 	}
 
Signature · 1 line
2.56.0.307.g5fe7bd680c-goog