[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 3/3] mkimage: Clarify file alignment in efi case
From: |
Alexander Graf |
Subject: |
[PATCH v5 3/3] mkimage: Clarify file alignment in efi case |
Date: |
Fri, 25 Jan 2019 12:45:16 +0100 |
There are a few spots in the PE generation code for EFI binaries that uses
the section alignment rather than file alignment, even though the alignment
is really only file bound.
Replace those cases with the file alignment constant instead.
Reported-by: Daniel Kiper <address@hidden>
Signed-off-by: Alexander Graf <address@hidden>
---
util/mkimage.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/util/mkimage.c b/util/mkimage.c
index 16af12e0c..6631bfe45 100644
--- a/util/mkimage.c
+++ b/util/mkimage.c
@@ -1227,10 +1227,10 @@ grub_install_generate_image (const char *dir, const
char *prefix,
header_size = EFI64_HEADER_SIZE;
reloc_addr = ALIGN_UP (header_size + core_size,
- image_target->section_align);
+ GRUB_PE32_FILE_ALIGNMENT);
pe_size = ALIGN_UP (reloc_addr + layout.reloc_size,
- image_target->section_align);
+ GRUB_PE32_FILE_ALIGNMENT);
pe_img = xmalloc (reloc_addr + layout.reloc_size);
memset (pe_img, 0, header_size);
memcpy ((char *) pe_img + header_size, core_img, core_size);
@@ -1280,7 +1280,7 @@ grub_install_generate_image (const char *dir, const char
*prefix,
o->image_base = 0;
o->section_alignment = grub_host_to_target32
(image_target->section_align);
- o->file_alignment = grub_host_to_target32
(image_target->section_align);
+ o->file_alignment = grub_host_to_target32
(GRUB_PE32_FILE_ALIGNMENT);
o->image_size = grub_host_to_target32 (pe_size);
o->header_size = grub_host_to_target32 (header_size);
o->subsystem = grub_host_to_target16
(GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
@@ -1315,7 +1315,7 @@ grub_install_generate_image (const char *dir, const char
*prefix,
o->code_base = grub_cpu_to_le32 (header_size);
o->image_base = 0;
o->section_alignment = grub_host_to_target32
(image_target->section_align);
- o->file_alignment = grub_host_to_target32
(image_target->section_align);
+ o->file_alignment = grub_host_to_target32
(GRUB_PE32_FILE_ALIGNMENT);
o->image_size = grub_host_to_target32 (pe_size);
o->header_size = grub_host_to_target32 (header_size);
o->subsystem = grub_host_to_target16
(GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
--
2.12.3