Commit f60ba9e5945 (util/mkimage: Refactor section setup to use a helper) added a helper function to setup PE sections. But it also changed how the raw data offsets were calculated since all the section sizes are aligned.
But for some platforms (i.e: ia64 and aa64) the kernel image size wasn't aligned using the section alignment, which causes the PE section headers to not match the actual section sizes in the PE32+ binary file. This caused problems on ia64 EFI machines, since the .data section size is bigger than the actual section in the PE32+ binary, overlapping with part of the mods section. That leads to GRUB not being able to load any built-in module. Fix it by aligning the kernel_size to the section alignment, that makes the sizes and offsets in the PE section headers to match the sections in the PE32+ binary file. Reported-by: John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de> Signed-off-by: Javier Martinez Canillas <javi...@redhat.com> --- Changes in v2: - Align up for any arch in the is_relocatable (image_target) patch and not only for MKIMAGE_ELF64 or EM_AARCH64 (suggested by Daniel Kiper). util/grub-mkimagexx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 00f49ccaaaf..73646f12f14 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -2388,6 +2388,11 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, layout->kernel_size += ALIGN_UP (layout->got_size, 16); } #endif + + if (image_target->id == IMAGE_EFI) + layout->kernel_size = ALIGN_UP (layout->kernel_size + image_target->vaddr_offset, + image_target->section_align) + - image_target->vaddr_offset; } else { -- 2.31.1 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel