summaryrefslogtreecommitdiffstats
path: root/src/boot/efi/pe.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-16 18:26:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-16 18:26:40 +0000
commit34f1d05ca3b350257f1d9ddb0aba57f129c27c67 (patch)
treeeccee464f1cccec702d6b9a87f1732c343bd74c2 /src/boot/efi/pe.c
parentAdding debian version 256.4-3. (diff)
downloadsystemd-34f1d05ca3b350257f1d9ddb0aba57f129c27c67.tar.xz
systemd-34f1d05ca3b350257f1d9ddb0aba57f129c27c67.zip
Merging upstream version 256.5.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boot/efi/pe.c')
-rw-r--r--src/boot/efi/pe.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/boot/efi/pe.c b/src/boot/efi/pe.c
index 829266b..fdca0c9 100644
--- a/src/boot/efi/pe.c
+++ b/src/boot/efi/pe.c
@@ -209,7 +209,7 @@ static uint32_t get_compatibility_entry_address(const DosFileHeader *dos, const
return 0;
}
-EFI_STATUS pe_kernel_info(const void *base, uint32_t *ret_compat_address) {
+EFI_STATUS pe_kernel_info(const void *base, uint32_t *ret_compat_address, size_t *ret_size_in_memory) {
assert(base);
assert(ret_compat_address);
@@ -221,6 +221,11 @@ EFI_STATUS pe_kernel_info(const void *base, uint32_t *ret_compat_address) {
if (!verify_pe(pe, /* allow_compatibility= */ true))
return EFI_LOAD_ERROR;
+ /* When allocating we need to also consider the virtual/uninitialized data sections, so parse it out
+ * of the SizeOfImage field in the PE header and return it */
+ if (ret_size_in_memory)
+ *ret_size_in_memory = pe->OptionalHeader.SizeOfImage;
+
/* Support for LINUX_INITRD_MEDIA_GUID was added in kernel stub 1.0. */
if (pe->OptionalHeader.MajorImageVersion < 1)
return EFI_UNSUPPORTED;