From 0d04635ef0e4fa0850716c03163e120c63125df7 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 5 Apr 2023 13:41:53 +0100 Subject: [efi] Remove redundant zero padding in PE header Hybrid bzImage and UEFI binaries (such as wimboot) require the PE header to be kept as small as possible, since the bzImage header starts at a fixed offset 0x1f1. The PE header currently includes 128 bytes of zero padding between the DOS and NT header portions. This padding has been present since commit 81d92c6 ("[efi] Add EFI image format and basic runtime environment") first added support for EFI images in iPXE, and was included on the basis of matching the observed behaviour of the Microsoft toolchain. There appears to be no requirement for this padding to exist: EDK2 binaries built with gcc include only 64 bytes of zero padding, Linux kernel binaries include 66 bytes of non-zero padding, and wimboot binaries include no padding at all. Remove the unnecessary padding between the DOS and NT header portions to minimise the overall size of the PE header. Signed-off-by: Michael Brown --- src/util/elf2efi.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/util/elf2efi.c b/src/util/elf2efi.c index cea9abf..159f14e 100644 --- a/src/util/elf2efi.c +++ b/src/util/elf2efi.c @@ -191,7 +191,6 @@ struct pe_relocs { struct pe_header { EFI_IMAGE_DOS_HEADER dos; - uint8_t padding[128]; EFI_IMAGE_NT_HEADERS nt; }; -- cgit v1.1