MdeModulePkg/PeiCore: avoid EFI_IMAGE_MACHINE_TYPE_SUPPORTED to check arch

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>
This commit is contained in:
Ard Biesheuvel 2017-03-27 13:22:16 +01:00
parent 9bca00be25
commit 6e7ec25aaa
1 changed files with 5 additions and 3 deletions

View File

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