efi_loader: correct SizeOfCode, SizeOfInitializedData
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 16 Jan 2025 11:39:08 +0000 (12:39 +0100)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Fri, 17 Jan 2025 19:31:26 +0000 (20:31 +0100)
commit216459d2cf36dca5cf646053c0700772eb3334e7
treec7d28850ba2e2fbca708bdab4e499e24d0e35499
parent6a628c15033ba4927afda4ed38244055f137ee59
efi_loader: correct SizeOfCode, SizeOfInitializedData

The fields SizeOfCode, SizeOfInitializedData, and SizeOfUninitializedData
are define in the PE-COFF specification [1].

* SizeOfCode must match the size of all .text sections.
* SizeOfInitializedData must match the size of all .data sections.
* SizeOfUninitializedData must match the size of all .bss sections.

We only have one .text and one .data section. SizeOfCode and
SizeOfInitializedData have to be calculated as the difference between
the end and the start of the respective section.

As we don't have any .bss sections in the generated EFI binaries.
SizeOfUninitializedData must remain 0.

[1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
arch/arm/lib/crt0_aarch64_efi.S
arch/arm/lib/crt0_arm_efi.S
arch/riscv/lib/crt0_riscv_efi.S