]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/PeiCore: avoid EFI_IMAGE_MACHINE_TYPE_SUPPORTED to check arch
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 27 Mar 2017 12:22:16 +0000 (13:22 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 29 Mar 2017 10:54:07 +0000 (11:54 +0100)
The EFI_IMAGE_MACHINE_TYPE_SUPPORTED() macro is abused in the PeiCore
code to decide whether the system we are compiling for can deal with
executable code being copied elsewhere and executed from there.

As stated in the comment, this is fundamentally a property of the compiler
target, and so this should be made dependent on MDE_CPU_xxx preprocessor
defines, and not on whether or not the runtime target can deal with
PE/COFF images of a certain machine type.

On X86/IA32, this mostly boils down to the same thing, but not on other
architectures, so let's clean this up.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Core/Pei/Image/Image.c

index c8bb2300a0a6681a7c58dca85fb2f1d8f22b343c..198541128512318af8a8c6fa0c53ae0718c9847b 100644 (file)
@@ -112,6 +112,7 @@ GetImageReadFunction (
   IN      PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
   )\r
 {\r
+#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
   PEI_CORE_INSTANCE     *Private;\r
   EFI_PHYSICAL_ADDRESS  MemoryBuffer;\r
 \r
@@ -119,8 +120,7 @@ GetImageReadFunction (
   MemoryBuffer = 0;\r
 \r
   if (Private->PeiMemoryInstalled  && (((Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnBoot)) || \r
-      ((Private->HobList.HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnS3Boot))) &&\r
-      (EFI_IMAGE_MACHINE_TYPE_SUPPORTED(EFI_IMAGE_MACHINE_X64) || EFI_IMAGE_MACHINE_TYPE_SUPPORTED(EFI_IMAGE_MACHINE_IA32))) {\r
+      ((Private->HobList.HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnS3Boot)))) {\r
     // \r
     // Shadow algorithm makes lots of non ANSI C assumptions and only works for IA32 and X64 \r
     //  compilers that have been tested\r
@@ -136,7 +136,9 @@ GetImageReadFunction (
   } else {\r
     ImageContext->ImageRead = PeiImageRead;\r
   }\r
-\r
+#else\r
+  ImageContext->ImageRead = PeiImageRead;\r
+#endif\r
   return EFI_SUCCESS;\r
 }\r
 /**\r