c0e647e util/mkimage: Fix wrong PE32+ section sizes for some arches

1 file Authored by javierm 2 years ago, Committed by Daniel Kiper 2 years ago,
    util/mkimage: Fix wrong PE32+ section sizes for some arches
    
    The 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.
    However, for some platforms, i.e ia64-efi and arm64-efi, the kernel image
    size is not aligned using the section alignment. This leads to the situation
    in which the mods section offset in its PE section header does not match its
    real placement in the PE file. So, finally the GRUB is not able to locate
    and load built-in modules.
    
    The problem surfaces on ia64-efi and arm64-efi because both platforms
    require additional relocation data which is added behind .bss section.
    So, we have to add some padding behind this extra data to make the
    beginning of mods section properly aligned in the PE file. Fix it by
    aligning the kernel_size to the section alignment. That makes the sizes
    and offsets in the PE section headers to match relevant sections in the
    PE32+ binary file.
    
    Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
    Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
    
        
file modified
+4 -0