]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
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)
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

index fe6eca576ec3245db7da31f4c336be3daae0cdcf..e21b54fdbcb233dfddcb14cb04269dd355ceb4df 100644 (file)
@@ -41,7 +41,7 @@ optional_header:
        .byte   0x02                            /* MajorLinkerVersion */
        .byte   0x14                            /* MinorLinkerVersion */
        .long   _etext - _start                 /* SizeOfCode */
-       .long   0                               /* SizeOfInitializedData */
+       .long   _data_size                      /* SizeOfInitializedData */
        .long   0                               /* SizeOfUninitializedData */
        .long   _start - ImageBase              /* AddressOfEntryPoint */
        .long   _start - ImageBase              /* BaseOfCode */
index b5dfd4e381955a105fedd55b4a7e234ea4035a3e..3664cce8412ec126592f81d421668d602b494b2d 100644 (file)
@@ -38,8 +38,8 @@ optional_header:
        .short  IMAGE_NT_OPTIONAL_HDR32_MAGIC   /* PE32 format */
        .byte   0x02                            /* MajorLinkerVersion */
        .byte   0x14                            /* MinorLinkerVersion */
-       .long   _edata - _start                 /* SizeOfCode */
-       .long   0                               /* SizeOfInitializedData */
+       .long   _etext - _start                 /* SizeOfCode */
+       .long   _data_size                      /* SizeOfInitializedData */
        .long   0                               /* SizeOfUninitializedData */
        .long   _start - image_base             /* AddressOfEntryPoint */
        .long   _start - image_base             /* BaseOfCode */
index c7a4559eac8e997ac5e2ebd7b229c6f88ffc77ce..9eacbe4a859b97bd75695d97c2349cd3a007c799 100644 (file)
@@ -63,8 +63,8 @@ optional_header:
        .short  PE_MAGIC                        /* PE32(+) format */
        .byte   0x02                            /* MajorLinkerVersion */
        .byte   0x14                            /* MinorLinkerVersion */
-       .long   _edata - _start                 /* SizeOfCode */
-       .long   0                               /* SizeOfInitializedData */
+       .long   _etext - _start                 /* SizeOfCode */
+       .long   _data_size                      /* SizeOfInitializedData */
        .long   0                               /* SizeOfUninitializedData */
        .long   _start - ImageBase              /* AddressOfEntryPoint */
        .long   _start - ImageBase              /* BaseOfCode */