diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c index ab8fb35ad..bfbd95aee 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linux.c @@ -117,6 +117,9 @@ grub_arch_efi_linux_load_image_header (grub_file_t file, return grub_error (GRUB_ERR_FILE_READ_ERROR, "failed to read COFF image header"); } + if (lh->pe_image_header.optional_header.magic != GRUB_PE32_NATIVE_MAGIC) + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "non-native image not supported"); + /* * Linux kernels built for any architecture are guaranteed to support the * LoadFile2 based initrd loading protocol if the image version is >= 1. diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h index 101859af1..4e6e9d254 100644 --- a/include/grub/efi/pe32.h +++ b/include/grub/efi/pe32.h @@ -267,6 +267,12 @@ struct grub_pe32_section_table #define GRUB_PE32_SIGNATURE_SIZE 4 +#if GRUB_TARGET_SIZEOF_VOID_P == 8 +#define GRUB_PE32_NATIVE_MAGIC GRUB_PE32_PE64_MAGIC +#else +#define GRUB_PE32_NATIVE_MAGIC GRUB_PE32_PE32_MAGIC +#endif + struct grub_pe_image_header { /* This is always PE\0\0. */