util/mkimage: Some fixes to PE binaries section size calculation
authorJavier Martinez Canillas <javierm@redhat.com>
Fri, 16 Apr 2021 19:37:23 +0000 (21:37 +0200)
committerFelix Zielcke <fzielcke@z-51.de>
Wed, 11 Jun 2025 15:42:34 +0000 (17:42 +0200)
commit8baac94d9e749a060bcc77ec978ec00a861d6e54
treec5160d28f1baac2a4ea79c5cda0299699062d9a4
parent54e172b236b95974765f9f54c782a001fa3ccbd1
util/mkimage: Some fixes to PE binaries section size calculation

Commit f60ba9e5945 (util/mkimage: Refactor section setup to use a helper)
added a helper function to setup PE sections, but it caused regressions
in some arches where the natural alignment lead to wrong section sizes.

This patch fixes a few things that were caused the section sizes to be
calculated wrongly. These fixes are:

 * Only align the virtual memory addresses but not the raw data offsets.
 * Use aligned sizes for virtual memory sizes but not for raw data sizes.
 * Always align the sizes to set the virtual memory sizes.

These seems to not cause problems for x64 and aa64 EFI platforms but was
a problem for ia64. Because the size of the ".data" and "mods" sections
were wrong and didn't have the correct content. Which lead to GRUB not
being able to load any built-in module.

Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Bug-Debian: https://bugs.debian.org/987103

Patch-Name: mkimage-fix-section-sizes.patch

Gbp-Pq: Name mkimage-fix-section-sizes.patch
util/mkimage.c