MdePkg/UefiImageLib: Support multi-format and multi-source architecture

Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
This commit is contained in:
Mikhail Krichanov 2023-12-18 11:01:58 +03:00
parent c01eab36cb
commit 5a8fe7214e
83 changed files with 1561 additions and 524 deletions

View File

@ -55,7 +55,6 @@
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf
CpuArchLib|ArmPkg/Library/CpuArchLib/CpuArchLib.inf CpuArchLib|ArmPkg/Library/CpuArchLib/CpuArchLib.inf

View File

@ -214,7 +214,12 @@ GetImageContext (
// Initialize the Image Context // Initialize the Image Context
// FIXME: Common FFS API with size checks // FIXME: Common FFS API with size checks
Status = UefiImageInitializeContext (ImageContext, EfiImage, SectionLength - sizeof (*Section)); Status = UefiImageInitializeContext (
ImageContext,
EfiImage,
SectionLength - sizeof (*Section),
UEFI_IMAGE_SOURCE_FV
);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
Status = UefiImageLoadImageInplace( ImageContext); Status = UefiImageLoadImageInplace( ImageContext);
} }

View File

@ -58,7 +58,6 @@
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClockLib.inf PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClockLib.inf
PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf

View File

@ -45,7 +45,6 @@
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicArmVirt.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicArmVirt.inf
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf

View File

@ -47,7 +47,7 @@
SerialPortLib SerialPortLib
ExtractGuidedSectionLib ExtractGuidedSectionLib
LzmaDecompressLib LzmaDecompressLib
UefiImageLib UefiImageOnlyFvLib
PrePiLib PrePiLib
MemoryAllocationLib MemoryAllocationLib
HobLib HobLib

View File

@ -152,7 +152,12 @@ RelocateUefiImage (
Status = FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &SectionData, &SectionSize); Status = FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &SectionData, &SectionSize);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = UefiImageInitializeContext (&ImageContext, SectionData, SectionSize); Status = UefiImageInitializeContext (
&ImageContext,
SectionData,
SectionSize,
UEFI_IMAGE_SOURCE_FV
);
ASSERT_RETURN_ERROR (Status); ASSERT_RETURN_ERROR (Status);
Status = UefiImageRelocateImageInplaceForExecution (&ImageContext); Status = UefiImageRelocateImageInplaceForExecution (&ImageContext);

View File

@ -10,7 +10,7 @@ OBJS = $(PROJECT).o
OBJS += Image.o UefiImageScan.o PeEmit32.o PeEmit64.o PeEmitCommon.o PeScan.o ElfScan32.o ElfScan64.o ElfScanCommon.o BinEmit.o ImageToolEmit.o OBJS += Image.o UefiImageScan.o PeEmit32.o PeEmit64.o PeEmitCommon.o PeScan.o ElfScan32.o ElfScan64.o ElfScanCommon.o BinEmit.o ImageToolEmit.o
OBJS += UefiImageExtraActionLib.o OBJS += UefiImageExtraActionLib.o
OBJS += PeCoffInit.o PeCoffInfo.o PeCoffLoad.o PeCoffRelocate.o PeCoffHii.o PeCoffDebug.o PeCoffHash.o OBJS += PeCoffInit.o PeCoffInfo.o PeCoffLoad.o PeCoffRelocate.o PeCoffHii.o PeCoffDebug.o PeCoffHash.o
OBJS += UefiImageLibPeCoff.o PeCoffSupport.o CommonSupport.o OBJS += PeSupport.o UefiImageLib.o CommonSupport.o
WERROR = 1 WERROR = 1
DEBUG = 1 DEBUG = 1
@ -23,3 +23,5 @@ VPATH += ../../MdePkg/Library/BasePeCoffLib2:$\
../../MdePkg/Library/BaseUefiImageLib ../../MdePkg/Library/BaseUefiImageLib
include $(OC_USER)/User/Makefile include $(OC_USER)/User/Makefile
CFLAGS += -DUEFI_IMAGE_FORMAT_SUPPORT_SOURCES=0x02

View File

@ -33,7 +33,7 @@ CMEM = $(UDK_PATH)\MdeModulePkg\Library\CommonMemoryAllocationLib
USER = $(OC_USER)\User\Library USER = $(OC_USER)\User\Library
OBJECTS = $(OBJECTS) {$(BASE)}SafeString.obj String.obj SwapBytes16.obj SwapBytes32.obj CpuDeadLoop.obj CheckSum.obj QuickSort.obj LinkedList.obj OBJECTS = $(OBJECTS) {$(BASE)}SafeString.obj String.obj SwapBytes16.obj SwapBytes32.obj CpuDeadLoop.obj CheckSum.obj QuickSort.obj LinkedList.obj
OBJECTS = $(OBJECTS) {$(OUT)}DebugLib.obj {$(PRIN)}PrintLib.obj PrintLibInternal.obj {$(ERRO)}BaseDebugPrintErrorLevelLib.obj OBJECTS = $(OBJECTS) {$(OUT)}DebugLib.obj {$(PRIN)}PrintLib.obj PrintLibInternal.obj {$(ERRO)}BaseDebugPrintErrorLevelLib.obj
OBJECTS = $(OBJECTS) {$(UIMG)}UefiImageLibPeCoff.obj PeCoffSupport.obj CommonSupport.obj OBJECTS = $(OBJECTS) {$(UIMG)}UefiImageLib.obj PeSupport.obj CommonSupport.obj
OBJECTS = $(OBJECTS) {$(USER)}UserFile.obj UserBaseMemoryLib.obj UserMath.obj UserPcd.obj UserMisc.obj UserGlobalVar.obj UserBootServices.obj OBJECTS = $(OBJECTS) {$(USER)}UserFile.obj UserBaseMemoryLib.obj UserMath.obj UserPcd.obj UserMisc.obj UserGlobalVar.obj UserBootServices.obj
OBJECTS = $(OBJECTS) {$(BMPN)}BaseMemoryProfileLibNull.obj {$(CMEM)}CommonMemoryAllocationLib.obj {$(CMEM)}CommonMemoryAllocationLibEx.obj OBJECTS = $(OBJECTS) {$(BMPN)}BaseMemoryProfileLibNull.obj {$(CMEM)}CommonMemoryAllocationLib.obj {$(CMEM)}CommonMemoryAllocationLibEx.obj
@ -102,7 +102,7 @@ cleanall:
@move $@ $(OUT_DIR)\ @move $@ $(OUT_DIR)\
{$(UIMG)}.c.obj : {$(UIMG)}.c.obj :
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@ $(CC) -c $(CFLAGS) -DUEFI_IMAGE_FORMAT_SUPPORT_SOURCES=0x02 $(INC) $< -Fo$@
@move $@ $(OUT_DIR)\ @move $@ $(OUT_DIR)\
{$(USER)}.c.obj : {$(USER)}.c.obj :

View File

@ -21,10 +21,7 @@ ScanUefiImageGetHeaderInfo (
RETURN_STATUS Status; RETURN_STATUS Status;
UINT64 Address; UINT64 Address;
assert (HeaderInfo != NULL); HeaderInfo->BaseAddress = UefiImageGetBaseAddress (Context);
assert (Context != NULL);
HeaderInfo->BaseAddress = UefiImageGetPreferredAddress (Context);
HeaderInfo->EntryPointAddress = UefiImageGetEntryPointAddress (Context); HeaderInfo->EntryPointAddress = UefiImageGetEntryPointAddress (Context);
HeaderInfo->Machine = UefiImageGetMachine (Context); HeaderInfo->Machine = UefiImageGetMachine (Context);
HeaderInfo->Subsystem = UefiImageGetSubsystem (Context); HeaderInfo->Subsystem = UefiImageGetSubsystem (Context);
@ -66,10 +63,7 @@ ScanUefiImageGetRelocInfo (
RelocInfo->RelocsStripped = UefiImageGetRelocsStripped (Context); RelocInfo->RelocsStripped = UefiImageGetRelocsStripped (Context);
if (FormatIndex == UefiImageFormatPe) { if (FormatIndex == UefiImageFormatPe) {
return ScanPeGetRelocInfo ( return ScanPeGetRelocInfo (RelocInfo, &Context->Ctx.Pe);
RelocInfo,
(PE_COFF_LOADER_IMAGE_CONTEXT *)Context
);
} }
fprintf ( fprintf (
@ -97,10 +91,7 @@ ScanUefiImageGetSegmentInfo (
SegmentInfo->SegmentAlignment = UefiImageGetSegmentAlignment (Context); SegmentInfo->SegmentAlignment = UefiImageGetSegmentAlignment (Context);
if (FormatIndex == UefiImageFormatPe) { if (FormatIndex == UefiImageFormatPe) {
return ScanPeGetSegmentInfo ( return ScanPeGetSegmentInfo (SegmentInfo, &Context->Ctx.Pe);
SegmentInfo,
(PE_COFF_LOADER_IMAGE_CONTEXT *)Context
);
} }
fprintf ( fprintf (
@ -211,7 +202,12 @@ ToolContextConstructUefiImage (
return RETURN_UNSUPPORTED; return RETURN_UNSUPPORTED;
} }
Status = UefiImageInitializeContext (&Context, File, (UINT32)FileSize); Status = UefiImageInitializeContext (
&Context,
File,
(UINT32)FileSize,
UEFI_IMAGE_SOURCE_FV
);
if (RETURN_ERROR (Status)) { if (RETURN_ERROR (Status)) {
return Status; return Status;
} }

View File

@ -122,8 +122,8 @@ OBJECTS += \
OBJECTS += \ OBJECTS += \
$(EDK2_OBJPATH)/MdePkg/Library/BaseUefiImageLib/CommonSupport.o \ $(EDK2_OBJPATH)/MdePkg/Library/BaseUefiImageLib/CommonSupport.o \
$(EDK2_OBJPATH)/MdePkg/Library/BaseUefiImageLib/PeCoffSupport.o \ $(EDK2_OBJPATH)/MdePkg/Library/BaseUefiImageLib/PeSupport.o \
$(EDK2_OBJPATH)/MdePkg/Library/BaseUefiImageLib/UefiImageLibPeCoff.o $(EDK2_OBJPATH)/MdePkg/Library/BaseUefiImageLib/UefiImageLib.o
OBJECTS += \ OBJECTS += \
$(EDK2_OBJPATH)/MdePkg/Library/BaseUefiImageExtraActionLibNull/UefiImageExtraActionLib.o $(EDK2_OBJPATH)/MdePkg/Library/BaseUefiImageExtraActionLibNull/UefiImageExtraActionLib.o

View File

@ -121,8 +121,8 @@ OBJECTS = $(OBJECTS) \
OBJECTS = $(OBJECTS) \ OBJECTS = $(OBJECTS) \
$(EDK2_OBJPATH)\MdePkg\Library\BaseUefiImageLib\CommonSupport.obj \ $(EDK2_OBJPATH)\MdePkg\Library\BaseUefiImageLib\CommonSupport.obj \
$(EDK2_OBJPATH)\MdePkg\Library\BaseUefiImageLib\PeCoffSupport.obj \ $(EDK2_OBJPATH)\MdePkg\Library\BaseUefiImageLib\PeSupport.obj \
$(EDK2_OBJPATH)\MdePkg\Library\BaseUefiImageLib\UefiImageLibPeCoff.obj $(EDK2_OBJPATH)\MdePkg\Library\BaseUefiImageLib\UefiImageLib.obj
OBJECTS = $(OBJECTS) \ OBJECTS = $(OBJECTS) \
$(EDK2_OBJPATH)\MdePkg\Library\BaseUefiImageExtraActionLibNull\UefiImageExtraActionLib.obj $(EDK2_OBJPATH)\MdePkg\Library\BaseUefiImageExtraActionLibNull\UefiImageExtraActionLib.obj

View File

@ -836,7 +836,12 @@ Returns:
RETURN_STATUS Status; RETURN_STATUS Status;
UEFI_IMAGE_LOADER_IMAGE_CONTEXT Context; UEFI_IMAGE_LOADER_IMAGE_CONTEXT Context;
Status = UefiImageInitializeContext (&Context, FileBuffer, FileSize); Status = UefiImageInitializeContext (
&Context,
FileBuffer,
FileSize,
UEFI_IMAGE_SOURCE_FV
);
if (RETURN_ERROR (Status)) { if (RETURN_ERROR (Status)) {
Error (NULL, 0, 2000, "Invalid parameter", "Input file does not appear to be an UEFI image - %llu!", Status); Error (NULL, 0, 2000, "Invalid parameter", "Input file does not appear to be an UEFI image - %llu!", Status);
return STATUS_ERROR; return STATUS_ERROR;

View File

@ -2389,7 +2389,12 @@ Returns:
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
RETURN_STATUS Status = UefiImageInitializeContext (&Context, UefiImage, UefiImageSize); RETURN_STATUS Status = UefiImageInitializeContext (
&Context,
UefiImage,
UefiImageSize,
UEFI_IMAGE_SOURCE_FV
);
if (RETURN_ERROR (Status)) { if (RETURN_ERROR (Status)) {
Error (NULL, 0, 3000, "Invalid", "Unrecognized UEFI image file."); Error (NULL, 0, 3000, "Invalid", "Unrecognized UEFI image file.");
return Status; return Status;
@ -3569,7 +3574,8 @@ Returns:
Status = UefiImageInitializeContext ( Status = UefiImageInitializeContext (
&ImageContext, &ImageContext,
(VOID *) ((UINTN) CurrentPe32Section.Pe32Section + CurSecHdrSize), (VOID *) ((UINTN) CurrentPe32Section.Pe32Section + CurSecHdrSize),
SectPeSize SectPeSize,
UEFI_IMAGE_SOURCE_FV
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Error (NULL, 0, 3000, "Invalid UefiImage", "The input file is %s and the return status is %x", FileName, (int) Status); Error (NULL, 0, 3000, "Invalid UefiImage", "The input file is %s and the return status is %x", FileName, (int) Status);
@ -3779,7 +3785,8 @@ Returns:
Status = UefiImageInitializeContext ( Status = UefiImageInitializeContext (
&ImageContext, &ImageContext,
(VOID *) ((UINTN) CurrentPe32Section.Pe32Section + CurSecHdrSize), (VOID *) ((UINTN) CurrentPe32Section.Pe32Section + CurSecHdrSize),
RebasedImageSize RebasedImageSize,
UEFI_IMAGE_SOURCE_FV
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);

View File

@ -163,6 +163,20 @@ extern UINT64 _gPcd_SkuId_Array[];
#define _PCD_GET_MODE_8_PcdDebugRaisePropertyMask _PCD_VALUE_PcdDebugRaisePropertyMask #define _PCD_GET_MODE_8_PcdDebugRaisePropertyMask _PCD_VALUE_PcdDebugRaisePropertyMask
//#define _PCD_SET_MODE_8_PcdDebugRaisePropertyMask ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD //#define _PCD_SET_MODE_8_PcdDebugRaisePropertyMask ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD
#define _PCD_TOKEN_PcdUefiImageFormatSupportNonFv 0U
#define _PCD_VALUE_PcdUefiImageFormatSupportNonFv 0x00
#define _PCD_SIZE_PcdUefiImageFormatSupportNonFv 1
#define _PCD_GET_MODE_SIZE_PcdUefiImageFormatSupportNonFv _PCD_SIZE_PcdUefiImageFormatSupportNonFv
#define _PCD_GET_MODE_8_PcdUefiImageFormatSupportNonFv _PCD_VALUE_PcdUefiImageFormatSupportNonFv
//#define _PCD_SET_MODE_8_PcdUefiImageFormatSupportNonFv ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD
#define _PCD_TOKEN_PcdUefiImageFormatSupportFv 0U
#define _PCD_VALUE_PcdUefiImageFormatSupportFv 0x01
#define _PCD_SIZE_PcdUefiImageFormatSupportFv 1
#define _PCD_GET_MODE_SIZE_PcdUefiImageFormatSupportFv _PCD_SIZE_PcdUefiImageFormatSupportFv
#define _PCD_GET_MODE_8_PcdUefiImageFormatSupportFv _PCD_VALUE_PcdUefiImageFormatSupportFv
//#define _PCD_SET_MODE_8_PcdUefiImageFormatSupportFv ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -138,6 +138,8 @@ ifeq ($(DARWIN),Darwin)
endif endif
endif endif
CFLAGS += -DUEFI_IMAGE_FORMAT_SUPPORT_SOURCES=0x02
# keep BUILD_OPTFLAGS last # keep BUILD_OPTFLAGS last
CFLAGS += $(BUILD_OPTFLAGS) CFLAGS += $(BUILD_OPTFLAGS)
CXXFLAGS += $(BUILD_OPTFLAGS) CXXFLAGS += $(BUILD_OPTFLAGS)

View File

@ -41,7 +41,7 @@
{$(EDK2_PATH)\MdePkg\Library\BaseUefiImageLib\}.c{$(EDK2_OBJPATH)\MdePkg\Library\BaseUefiImageLib\}.obj : {$(EDK2_PATH)\MdePkg\Library\BaseUefiImageLib\}.c{$(EDK2_OBJPATH)\MdePkg\Library\BaseUefiImageLib\}.obj :
-@if not exist $(@D)\ mkdir $(@D) -@if not exist $(@D)\ mkdir $(@D)
$(CC) -c $(CFLAGS) $(EDK2_INC) $< -Fo$@ $(CC) -c $(CFLAGS) -DUEFI_IMAGE_FORMAT_SUPPORT_SOURCES=0x02 $(EDK2_INC) $< -Fo$@
{$(EDK2_PATH)\MdePkg\Library\BaseUefiImageExtraActionLibNull\}.c{$(EDK2_OBJPATH)\MdePkg\Library\BaseUefiImageExtraActionLibNull\}.obj : {$(EDK2_PATH)\MdePkg\Library\BaseUefiImageExtraActionLibNull\}.c{$(EDK2_OBJPATH)\MdePkg\Library\BaseUefiImageExtraActionLibNull\}.obj :
-@if not exist $(@D)\ mkdir $(@D) -@if not exist $(@D)\ mkdir $(@D)

View File

@ -59,7 +59,6 @@
ReportStatusCodeLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf ReportStatusCodeLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf

View File

@ -40,7 +40,12 @@ LoadUefiImage (
UINT32 BufferPages; UINT32 BufferPages;
UINT32 BufferAlignment; UINT32 BufferAlignment;
Status = UefiImageInitializeContext (&ImageContext, UefiImage, UefiImageSize); Status = UefiImageInitializeContext (
&ImageContext,
UefiImage,
UefiImageSize,
UEFI_IMAGE_SOURCE_FV
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
ImageSize = UefiImageGetImageSize (&ImageContext); ImageSize = UefiImageGetImageSize (&ImageContext);

View File

@ -63,7 +63,6 @@
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf

View File

@ -746,7 +746,12 @@ SecUefiImageGetEntryPoint (
EFI_STATUS Status; EFI_STATUS Status;
UEFI_IMAGE_LOADER_IMAGE_CONTEXT ImageContext; UEFI_IMAGE_LOADER_IMAGE_CONTEXT ImageContext;
Status = UefiImageInitializeContext (&ImageContext, Pe32Data, Pe32Size); Status = UefiImageInitializeContext (
&ImageContext,
Pe32Data,
Pe32Size,
UEFI_IMAGE_SOURCE_FV
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }

View File

@ -55,7 +55,7 @@
PrintLib PrintLib
BaseMemoryLib BaseMemoryLib
BaseLib BaseLib
UefiImageLib UefiImageOnlyFvLib
ThunkPpiList ThunkPpiList
ThunkProtocolList ThunkProtocolList
PpiListLib PpiListLib

View File

@ -804,7 +804,12 @@ SecUefiImageGetEntryPoint (
EFI_STATUS Status; EFI_STATUS Status;
UEFI_IMAGE_LOADER_IMAGE_CONTEXT ImageContext; UEFI_IMAGE_LOADER_IMAGE_CONTEXT ImageContext;
Status = UefiImageInitializeContext (&ImageContext, Pe32Data, Pe32Size); Status = UefiImageInitializeContext (
&ImageContext,
Pe32Data,
Pe32Size,
UEFI_IMAGE_SOURCE_FV
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }

View File

@ -49,7 +49,7 @@
PrintLib PrintLib
BaseMemoryLib BaseMemoryLib
BaseLib BaseLib
UefiImageLib UefiImageOnlyFvLib
ThunkPpiList ThunkPpiList
ThunkProtocolList ThunkProtocolList
PpiListLib PpiListLib

View File

@ -93,7 +93,6 @@
ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf

View File

@ -39,7 +39,7 @@
BaseMemoryLib BaseMemoryLib
UefiLib UefiLib
FspWrapperApiLib FspWrapperApiLib
UefiImageLib UefiImageOnlyFvLib
CacheMaintenanceLib CacheMaintenanceLib
DxeServicesLib DxeServicesLib
PerformanceLib PerformanceLib

View File

@ -90,7 +90,12 @@ RelocateImageUnder4GIfNeeded (
// //
// Get information about the image being loaded // Get information about the image being loaded
// //
Status = UefiImageInitializeContext (&ImageContext, Buffer, (UINT32) BufferSize); Status = UefiImageInitializeContext (
&ImageContext,
Buffer,
(UINT32) BufferSize,
UEFI_IMAGE_SOURCE_FV
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
ImageSize = UefiImageGetImageSize (&ImageContext); ImageSize = UefiImageGetImageSize (&ImageContext);
ImageAlignment = UefiImageGetSegmentAlignment (&ImageContext); ImageAlignment = UefiImageGetSegmentAlignment (&ImageContext);

View File

@ -29,7 +29,6 @@
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf

View File

@ -83,7 +83,7 @@
UefiLib UefiLib
DebugLib DebugLib
DxeCoreEntryPoint DxeCoreEntryPoint
UefiImageLib UefiImageAllLib
UefiImageExtraActionLib UefiImageExtraActionLib
ExtractGuidedSectionLib ExtractGuidedSectionLib
MemoryAllocationLib MemoryAllocationLib

View File

@ -239,12 +239,17 @@ CoreInitializeImageServices (
Status = UefiImageInitializeContext ( Status = UefiImageInitializeContext (
ImageContext, ImageContext,
(VOID *) (UINTN) DxeCoreImageBaseAddress, (VOID *) (UINTN) DxeCoreImageBaseAddress,
(UINT32) DxeCoreImageLength (UINT32) DxeCoreImageLength,
UEFI_IMAGE_SOURCE_FV
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// FIXME: DxeCore is dynamically loaded by DxeIpl, can't it pass the context? // FIXME: DxeCore is dynamically loaded by DxeIpl, can't it pass the context?
ImageContext->ImageBuffer = (VOID *) ImageContext->FileBuffer; if (ImageContext->FormatIndex == UefiImageFormatPe) {
ImageContext->Ctx.Pe.ImageBuffer = (VOID *) ImageContext->Ctx.Pe.FileBuffer;
} else {
ASSERT (FALSE);
}
ASSERT ((UINTN) DxeCoreEntryPoint == UefiImageLoaderGetImageEntryPoint (ImageContext)); ASSERT ((UINTN) DxeCoreEntryPoint == UefiImageLoaderGetImageEntryPoint (ImageContext));
@ -590,7 +595,7 @@ CoreLoadPeImage (
Status = GetUefiImageFixLoadingAssignedAddress (&BufferAddress, ValueInSectionHeader, DstBufSize); Status = GetUefiImageFixLoadingAssignedAddress (&BufferAddress, ValueInSectionHeader, DstBufSize);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
if (BufferAddress != UefiImageGetPreferredAddress (ImageContext) && UefiImageGetRelocsStripped (ImageContext)) { if (BufferAddress != UefiImageGetBaseAddress (ImageContext) && UefiImageGetRelocsStripped (ImageContext)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED ERROR: Loading module at fixed address failed since relocs have been stripped.\n")); DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED ERROR: Loading module at fixed address failed since relocs have been stripped.\n"));
} }
@ -602,7 +607,7 @@ CoreLoadPeImage (
} }
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
BufferAddress = UefiImageGetPreferredAddress (ImageContext); BufferAddress = UefiImageGetBaseAddress (ImageContext);
if ((BufferAddress >= 0x100000) || UefiImageGetRelocsStripped (ImageContext)) { if ((BufferAddress >= 0x100000) || UefiImageGetRelocsStripped (ImageContext)) {
Status = AllocatePagesEx ( Status = AllocatePagesEx (
AllocateAddress, AllocateAddress,
@ -1191,7 +1196,12 @@ CoreLoadImageCommon (
// //
// Get information about the image being loaded // Get information about the image being loaded
// //
Status = UefiImageInitializeContextPreHash (&ImageContext, FHand.Source, (UINT32) FHand.SourceSize); Status = UefiImageInitializeContextPreHash (
&ImageContext,
FHand.Source,
(UINT32) FHand.SourceSize,
ImageIsFromFv
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ASSERT (FALSE); ASSERT (FALSE);
return Status; return Status;

View File

@ -183,7 +183,12 @@ LoadAndRelocateUefiImage (
ReturnStatus = EFI_SUCCESS; ReturnStatus = EFI_SUCCESS;
Status = UefiImageInitializeContext (ImageContext, Pe32Data, Pe32DataSize); Status = UefiImageInitializeContext (
ImageContext,
Pe32Data,
Pe32DataSize,
UEFI_IMAGE_SOURCE_FV
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -270,7 +275,7 @@ LoadAndRelocateUefiImage (
} }
if (!EFI_ERROR (Status)){ if (!EFI_ERROR (Status)){
Success = Destination == UefiImageGetPreferredAddress (ImageContext); Success = Destination == UefiImageGetBaseAddress (ImageContext);
if (!Success) { if (!Success) {
DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED ERROR: Loading module at fixed address failed since relocs have been stripped.\n")); DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED ERROR: Loading module at fixed address failed since relocs have been stripped.\n"));
@ -362,7 +367,12 @@ LoadAndRelocateUefiImageInPlace (
CopyMem (ImageAddress, Pe32Data, ImageSize); CopyMem (ImageAddress, Pe32Data, ImageSize);
Status = UefiImageInitializeContext (&ImageContext, ImageAddress, ImageSize); Status = UefiImageInitializeContext (
&ImageContext,
ImageAddress,
ImageSize,
UEFI_IMAGE_SOURCE_FV
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return Status; return Status;

View File

@ -62,7 +62,7 @@
DebugLib DebugLib
MemoryAllocationLib MemoryAllocationLib
CacheMaintenanceLib CacheMaintenanceLib
UefiImageLib UefiImageOnlyFvLib
PeiServicesTablePointerLib PeiServicesTablePointerLib
PcdLib PcdLib

View File

@ -1117,7 +1117,12 @@ ConvertPeiCorePpiPointers (
// Find PEI Core EntryPoint in the BFV in temporary memory. // Find PEI Core EntryPoint in the BFV in temporary memory.
// //
// FIXME: "Assume" sanity and skip full initialisation? // FIXME: "Assume" sanity and skip full initialisation?
Status = UefiImageInitializeContext (&ImageContext, (VOID *) (UINTN) PeiCoreImageBase, PeiCoreImageSize); Status = UefiImageInitializeContext (
&ImageContext,
(VOID *) (UINTN) PeiCoreImageBase,
PeiCoreImageSize,
UEFI_IMAGE_SOURCE_FV
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
OrgImageBase = (UINTN)PeiCoreImageBase; OrgImageBase = (UINTN)PeiCoreImageBase;

View File

@ -339,7 +339,12 @@ SmmLoadImage (
// //
// Get information about the image being loaded // Get information about the image being loaded
// //
Status = UefiImageInitializeContextPreHash (ImageContext, Buffer, (UINT32) Size); Status = UefiImageInitializeContextPreHash (
ImageContext,
Buffer,
(UINT32) Size,
UEFI_IMAGE_SOURCE_FV
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Buffer != NULL) { if (Buffer != NULL) {
gBS->FreePool (Buffer); gBS->FreePool (Buffer);

View File

@ -48,7 +48,7 @@
UefiDriverEntryPoint UefiDriverEntryPoint
BaseLib BaseLib
BaseMemoryLib BaseMemoryLib
UefiImageLib UefiImageOnlyFvLib
CacheMaintenanceLib CacheMaintenanceLib
DebugLib DebugLib
ReportStatusCodeLib ReportStatusCodeLib

View File

@ -1003,7 +1003,12 @@ ExecuteSmmCoreFromSmram (
// //
// Get information about the image being loaded // Get information about the image being loaded
// //
Status = UefiImageInitializeContext (&gSmmCorePrivate->PiSmmCoreImageContext, SourceBuffer, (UINT32) SourceSize); Status = UefiImageInitializeContext (
&gSmmCorePrivate->PiSmmCoreImageContext,
SourceBuffer,
(UINT32) SourceSize,
UEFI_IMAGE_SOURCE_FV
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }

View File

@ -35,7 +35,7 @@
UefiDriverEntryPoint UefiDriverEntryPoint
BaseLib BaseLib
BaseMemoryLib BaseMemoryLib
UefiImageLib UefiImageOnlyFvLib
CacheMaintenanceLib CacheMaintenanceLib
MemoryAllocationLib MemoryAllocationLib
DebugLib DebugLib

View File

@ -39,7 +39,7 @@
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
[LibraryClasses] [LibraryClasses]
UefiImageLib UefiImageAllLib
CacheMaintenanceLib CacheMaintenanceLib
UefiBootServicesTableLib UefiBootServicesTableLib
UefiLib UefiLib

View File

@ -44,7 +44,6 @@
PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
# #
# UEFI & PI # UEFI & PI

View File

@ -49,7 +49,7 @@
UefiDriverEntryPoint UefiDriverEntryPoint
BaseLib BaseLib
S3BootScriptLib S3BootScriptLib
UefiImageLib UefiImageOnlyFvLib
DxeServicesLib DxeServicesLib
UefiBootServicesTableLib UefiBootServicesTableLib
CacheMaintenanceLib CacheMaintenanceLib

View File

@ -310,7 +310,12 @@ ReadyToLockEventNotify (
// //
// Get information about the image being loaded // Get information about the image being loaded
// //
Status = UefiImageInitializeContext (&ImageContext, Buffer, (UINT32) BufferSize); Status = UefiImageInitializeContext (
&ImageContext,
Buffer,
(UINT32) BufferSize,
UEFI_IMAGE_SOURCE_FV
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
ImageSize = UefiImageGetImageSize (&ImageContext); ImageSize = UefiImageGetImageSize (&ImageContext);
ImageAlignment = UefiImageGetSegmentAlignment (&ImageContext); ImageAlignment = UefiImageGetSegmentAlignment (&ImageContext);

View File

@ -497,19 +497,6 @@ PeCoffGetSizeOfImage (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context
); );
/**
Retrieves the size, in Bytes, of the Image memory space for in-place loading.
@param[in,out] Context The context describing the Image. Must have been
initialised by PeCoffInitializeContext().
@returns The size of the Image memory space for in-place loading.
**/
UINT32
PeCoffGetSizeOfImageInplace (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context
);
/** /**
Retrieves the Image preferred load address. Retrieves the Image preferred load address.

View File

@ -2,18 +2,28 @@
#ifndef UEFI_IMAGE_LIB_H_ #ifndef UEFI_IMAGE_LIB_H_
#define UEFI_IMAGE_LIB_H_ #define UEFI_IMAGE_LIB_H_
#include <Library/PeCoffLib2.h>
typedef enum { typedef enum {
UefiImageFormatPe = 0, UefiImageFormatPe = 0,
UefiImageFormatMax UefiImageFormatMax
} UEFI_IMAGE_FORMAT; } UEFI_IMAGE_FORMAT;
// FIXME: Work on reasonable abstraction #define UEFI_IMAGE_SOURCE_NON_FV 0U
#ifndef UEFI_IMAGE_LOADER_IMAGE_CONTEXT #define UEFI_IMAGE_SOURCE_FV 1U
#include <Library/PeCoffLib2.h> #define UEFI_IMAGE_SOURCE_ALL 2U
#define UEFI_IMAGE_SOURCE_MAX 3U
#define UEFI_IMAGE_LOADER_IMAGE_CONTEXT PE_COFF_LOADER_IMAGE_CONTEXT typedef UINT8 UEFI_IMAGE_SOURCE;
#define UEFI_IMAGE_LOADER_RUNTIME_CONTEXT PE_COFF_LOADER_RUNTIME_CONTEXT
#endif typedef struct {
UINT8 FormatIndex;
union {
PE_COFF_LOADER_IMAGE_CONTEXT Pe;
} Ctx;
} UEFI_IMAGE_LOADER_IMAGE_CONTEXT;
typedef struct UEFI_IMAGE_LOADER_RUNTIME_CONTEXT_ UEFI_IMAGE_LOADER_RUNTIME_CONTEXT;
/// ///
/// Image record segment that desribes the UEFI memory permission configuration /// Image record segment that desribes the UEFI memory permission configuration
@ -95,7 +105,8 @@ RETURN_STATUS
UefiImageInitializeContextPreHash ( UefiImageInitializeContextPreHash (
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context, OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN CONST VOID *FileBuffer, IN CONST VOID *FileBuffer,
IN UINT32 FileSize IN UINT32 FileSize,
IN UEFI_IMAGE_SOURCE Source
); );
RETURN_STATUS RETURN_STATUS
@ -122,7 +133,8 @@ RETURN_STATUS
UefiImageInitializeContext ( UefiImageInitializeContext (
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context, OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN CONST VOID *FileBuffer, IN CONST VOID *FileBuffer,
IN UINT32 FileSize IN UINT32 FileSize,
IN UEFI_IMAGE_SOURCE Source
); );
/** /**
@ -235,7 +247,7 @@ UefiImageLoaderGetRuntimeContextSize (
Relocate the Image for boot-time usage. Relocate the Image for boot-time usage.
May only be called when UefiImageGetRelocsStripped() returns FALSE, or with May only be called when UefiImageGetRelocsStripped() returns FALSE, or with
BaseAddress == UefiImageGetPreferredAddress(). BaseAddress == UefiImageGetBaseAddress().
@param[in,out] Context The context describing the Image. Must have @param[in,out] Context The context describing the Image. Must have
been loaded by UefiImageLoadImage(). been loaded by UefiImageLoadImage().
@ -263,7 +275,7 @@ UefiImageRelocateImage (
the Image. the Image.
May only be called when UefiImageGetRelocsStripped() returns FALSE, or with May only be called when UefiImageGetRelocsStripped() returns FALSE, or with
BaseAddress == UefiImageGetPreferredAddress(). BaseAddress == UefiImageGetBaseAddress().
@param[in,out] Context The context describing the Image. Must have @param[in,out] Context The context describing the Image. Must have
been initialised by been initialised by
@ -296,7 +308,7 @@ UefiImageLoadImageForExecution (
Relocate Image for Runtime usage. Relocate Image for Runtime usage.
May only be called when UefiImageGetRelocsStripped() returns FALSE, or with May only be called when UefiImageGetRelocsStripped() returns FALSE, or with
BaseAddress == UefiImageGetPreferredAddress(). BaseAddress == UefiImageGetBaseAddress().
@param[in,out] Image The Image destination memory. Must have been @param[in,out] Image The Image destination memory. Must have been
relocated by UefiImageRelocateImage(). relocated by UefiImageRelocateImage().
@ -321,7 +333,7 @@ UefiImageRuntimeRelocateImage (
required to execute code from the Image. required to execute code from the Image.
May only be called when UefiImageGetRelocsStripped() returns FALSE, or with May only be called when UefiImageGetRelocsStripped() returns FALSE, or with
BaseAddress == UefiImageGetPreferredAddress(). BaseAddress == UefiImageGetBaseAddress().
@param[in,out] Image The Image destination memory. Must have been @param[in,out] Image The Image destination memory. Must have been
relocated by UefiImageRelocateImage(). relocated by UefiImageRelocateImage().
@ -521,12 +533,6 @@ UefiImageGetImageSize (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
); );
// FIXME: Docs
UINT32
UefiImageGetImageSizeInplace (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
/** /**
Retrieves the Image preferred load address. Retrieves the Image preferred load address.
@ -536,7 +542,7 @@ UefiImageGetImageSizeInplace (
@returns The Image preferred load address. @returns The Image preferred load address.
**/ **/
UINT64 UINT64
UefiImageGetPreferredAddress ( UefiImageGetBaseAddress (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
); );

View File

@ -70,16 +70,6 @@ PeCoffGetSizeOfImage (
return Context->SizeOfImage; return Context->SizeOfImage;
} }
UINT32
PeCoffGetSizeOfImageInplace (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context
)
{
ASSERT (Context != NULL);
return Context->SizeOfImage;
}
UINT64 UINT64
PeCoffGetImageBase ( PeCoffGetImageBase (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context

View File

@ -0,0 +1,48 @@
## @file
# UEFI Image Loader library implementation for UE FV and PE non-FV Images.
#
# Copyright (c) 2023, Marvin Häuser. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-3-Clause
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BaseUefiImageLibAll
FILE_GUID = 499d294d-9f0f-4e8d-82fa-1892e6378996
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = UefiImageLib
LIBRARY_CLASS = UefiImageAllLib
[Sources]
CommonSupport.c
ExecutionSupport.c
PeSupport.c
UefiImageLib.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
BaseLib
BaseOverflowLib
BaseMemoryLib
CacheMaintenanceLib
DebugLib
MemoryAllocationLib
PeCoffLib2
UefiImageExtraActionLib
[FixedPcd]
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderAlignmentPolicy
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderLoadHeader
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderRemoveXForWX
gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask
gEfiMdePkgTokenSpaceGuid.PcdUefiImageFormatSupportNonFv
gEfiMdePkgTokenSpaceGuid.PcdUefiImageFormatSupportFv
[BuildOptions]
*_*_*_CC_FLAGS = -DUEFI_IMAGE_FORMAT_SUPPORT_SOURCES=0x03
MSFT:*_*_*_CC_FLAGS = /wd4204

View File

@ -1,25 +1,25 @@
## @file ## @file
# UEFI Image Loader library implementation for PE/COFF Images. # UEFI Image Loader library implementation for UE FV Images.
# #
# Copyright (c) 2021, Marvin Häuser. All rights reserved.<BR> # Copyright (c) 2023, Marvin Häuser. All rights reserved.<BR>
# #
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
## ##
[Defines] [Defines]
INF_VERSION = 0x00010005 INF_VERSION = 0x00010005
BASE_NAME = BaseUefiImageLibPeCoff BASE_NAME = BaseUefiImageLibOnlyFv
FILE_GUID = 357AD87E-8D6B-468A-B3FA-0D9CC4C725CD FILE_GUID = 11bb7a90-175d-4117-a66f-65b84a9544b7
MODULE_TYPE = BASE MODULE_TYPE = BASE
VERSION_STRING = 1.0 VERSION_STRING = 1.0
LIBRARY_CLASS = UefiImageLib LIBRARY_CLASS = UefiImageLib
LIBRARY_CLASS = UefiImageOnlyFvLib
[Sources] [Sources]
CommonSupport.c CommonSupport.c
ExecutionSupport.c ExecutionSupport.c
PeCoffSupport.h PeSupport.c
PeCoffSupport.c UefiImageLib.c
UefiImageLibPeCoff.c
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
@ -39,3 +39,9 @@
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderLoadHeader gEfiMdePkgTokenSpaceGuid.PcdImageLoaderLoadHeader
gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderRemoveXForWX gEfiMdePkgTokenSpaceGuid.PcdImageLoaderRemoveXForWX
gEfiMdePkgTokenSpaceGuid.PcdUefiImageFormatSupportNonFv
gEfiMdePkgTokenSpaceGuid.PcdUefiImageFormatSupportFv
[BuildOptions]
*_*_*_CC_FLAGS = -DUEFI_IMAGE_FORMAT_SUPPORT_SOURCES=0x02
MSFT:*_*_*_CC_FLAGS = /wd4204

View File

@ -0,0 +1,48 @@
## @file
# UEFI Image Loader library implementation for UE non-FV Images.
#
# Copyright (c) 2023, Marvin Häuser. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-3-Clause
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BaseUefiImageLibOnlyNonFv
FILE_GUID = 297b4e3e-2cfa-4350-8fa5-ad11dec48e75
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = UefiImageLib
LIBRARY_CLASS = UefiImageOnlyNonFvLib
[Sources]
CommonSupport.c
ExecutionSupport.c
PeSupport.c
UefiImageLib.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
BaseLib
BaseOverflowLib
BaseMemoryLib
CacheMaintenanceLib
DebugLib
MemoryAllocationLib
PeCoffLib2
UefiImageExtraActionLib
[FixedPcd]
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderAlignmentPolicy
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderLoadHeader
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderRemoveXForWX
gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask
gEfiMdePkgTokenSpaceGuid.PcdUefiImageFormatSupportNonFv
gEfiMdePkgTokenSpaceGuid.PcdUefiImageFormatSupportFv
[BuildOptions]
*_*_*_CC_FLAGS = -DUEFI_IMAGE_FORMAT_SUPPORT_SOURCES=0x01
MSFT:*_*_*_CC_FLAGS = /wd4204

View File

@ -18,12 +18,18 @@ RETURN_STATUS
UefiImageInitializeContext ( UefiImageInitializeContext (
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context, OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN CONST VOID *FileBuffer, IN CONST VOID *FileBuffer,
IN UINT32 FileSize IN UINT32 FileSize,
IN UEFI_IMAGE_SOURCE Source
) )
{ {
RETURN_STATUS Status; RETURN_STATUS Status;
Status = UefiImageInitializeContextPreHash (Context, FileBuffer, FileSize); Status = UefiImageInitializeContextPreHash (
Context,
FileBuffer,
FileSize,
Source
);
if (RETURN_ERROR (Status)) { if (RETURN_ERROR (Status)) {
return Status; return Status;
} }
@ -31,6 +37,14 @@ UefiImageInitializeContext (
return UefiImageInitializeContextPostHash (Context); return UefiImageInitializeContextPostHash (Context);
} }
UINT8
UefiImageGetFormat (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return Context->FormatIndex;
}
UINTN UINTN
UefiImageLoaderGetImageEntryPoint ( UefiImageLoaderGetImageEntryPoint (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context

View File

@ -30,7 +30,7 @@ UefiImageRelocateImageInplaceForExecution (
} }
ImageAddress = UefiImageLoaderGetImageAddress (Context); ImageAddress = UefiImageLoaderGetImageAddress (Context);
ImageSize = UefiImageGetImageSizeInplace (Context); ImageSize = UefiImageGetImageSize (Context);
// //
// Flush the instruction cache so the image data is written before // Flush the instruction cache so the image data is written before
// execution. // execution.

View File

@ -1,37 +0,0 @@
/** @file
UEFI Image Loader library implementation for PE/COFF Images.
Copyright (c) 2021, Marvin Häuser. All rights reserved.<BR>
SPDX-License-Identifier: BSD-3-Clause
**/
#ifndef PE_COFF_SUPPORT_H_
#define PE_COFF_SUPPORT_H_
#include <Library/PeCoffLib2.h>
#include <Library/UefiImageLib.h>
UEFI_IMAGE_RECORD *
UefiImageLoaderGetImageRecordPeCoff (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context
);
RETURN_STATUS
UefiImageDebugLocateImagePeCoff (
OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context,
IN UINTN Address
);
RETURN_STATUS
UefiImageGetFixedAddressPeCoff (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context,
OUT UINT64 *Address
);
VOID
UefiImageDebugPrintSegmentsPeCoff (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context
);
#endif // PE_COFF_SUPPORT_H_

View File

@ -19,6 +19,222 @@
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/PeCoffLib2.h> #include <Library/PeCoffLib2.h>
#include <Library/UefiImageLib.h> #include <Library/UefiImageLib.h>
#include <Library/PcdLib.h>
#include "PeSupport.h"
RETURN_STATUS
UefiImageInitializeContextPreHashPe (
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN CONST VOID *FileBuffer,
IN UINT32 FileSize
)
{
return PeCoffInitializeContext (&Context->Ctx.Pe, FileBuffer, FileSize);
}
BOOLEAN
UefiImageHashImageDefaultPe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN OUT VOID *HashContext,
IN UEFI_IMAGE_LOADER_HASH_UPDATE HashUpdate
)
{
return PeCoffHashImageAuthenticode (&Context->Ctx.Pe, HashContext, HashUpdate);
}
RETURN_STATUS
UefiImageInitializeContextPostHashPe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return RETURN_SUCCESS;
}
RETURN_STATUS
UefiImageLoadImagePe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT VOID *Destination,
IN UINT32 DestinationSize
)
{
return PeCoffLoadImage (&Context->Ctx.Pe, Destination, DestinationSize);
}
BOOLEAN
UefiImageImageIsInplacePe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffImageIsInplace (&Context->Ctx.Pe);
}
RETURN_STATUS
UefiImageLoadImageInplacePe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffLoadImageInplace (&Context->Ctx.Pe);
}
RETURN_STATUS
UefiImageRelocateImageInplacePe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffRelocateImageInplace (&Context->Ctx.Pe);
}
RETURN_STATUS
UefiImageLoaderGetRuntimeContextSizePe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT UINT32 *Size
)
{
return PeCoffLoaderGetRuntimeContextSize (&Context->Ctx.Pe, Size);
}
RETURN_STATUS
UefiImageRelocateImagePe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN UINT64 BaseAddress,
OUT UEFI_IMAGE_LOADER_RUNTIME_CONTEXT *RuntimeContext OPTIONAL,
IN UINT32 RuntimeContextSize
)
{
return PeCoffRelocateImage (
&Context->Ctx.Pe,
BaseAddress,
(PE_COFF_LOADER_RUNTIME_CONTEXT *)RuntimeContext,
RuntimeContextSize
);
}
RETURN_STATUS
UefiImageRuntimeRelocateImagePe (
IN OUT VOID *Image,
IN UINT32 ImageSize,
IN UINT64 BaseAddress,
IN CONST VOID *RuntimeContext
)
{
return PeCoffRuntimeRelocateImage (
Image,
ImageSize,
BaseAddress,
(CONST PE_COFF_LOADER_RUNTIME_CONTEXT *)RuntimeContext
);
}
VOID
UefiImageDiscardSegmentsPe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
PeCoffDiscardSections (&Context->Ctx.Pe);
}
RETURN_STATUS
UefiImageGetSymbolsPathPe (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT CONST CHAR8 **SymbolsPath,
OUT UINT32 *SymbolsPathSize
)
{
return PeCoffGetPdbPath (&Context->Ctx.Pe, SymbolsPath, SymbolsPathSize);
}
RETURN_STATUS
UefiImageGetFirstCertificatePe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT CONST WIN_CERTIFICATE **Certificate
)
{
return PeCoffGetFirstCertificate (&Context->Ctx.Pe, Certificate);
}
RETURN_STATUS
UefiImageGetNextCertificatePe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN OUT CONST WIN_CERTIFICATE **Certificate
)
{
return PeCoffGetNextCertificate (&Context->Ctx.Pe, Certificate);
}
RETURN_STATUS
UefiImageGetHiiDataRvaPe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT UINT32 *HiiRva,
OUT UINT32 *HiiSize
)
{
return PeCoffGetHiiDataRva (&Context->Ctx.Pe, HiiRva, HiiSize);
}
UINT32
UefiImageGetEntryPointAddressPe (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetAddressOfEntryPoint (&Context->Ctx.Pe);
}
UINT16
UefiImageGetMachinePe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetMachine (&Context->Ctx.Pe);
}
UINT16
UefiImageGetSubsystemPe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetSubsystem (&Context->Ctx.Pe);
}
UINT32
UefiImageGetSegmentAlignmentPe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetSectionAlignment (&Context->Ctx.Pe);
}
UINT32
UefiImageGetImageSizePe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetSizeOfImage (&Context->Ctx.Pe);
}
UINT64
UefiImageGetBaseAddressPe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetImageBase (&Context->Ctx.Pe);
}
BOOLEAN
UefiImageGetRelocsStrippedPe (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetRelocsStripped (&Context->Ctx.Pe);
}
UINTN
UefiImageLoaderGetImageAddressPe (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffLoaderGetImageAddress (&Context->Ctx.Pe);
}
/** /**
Retrieves the memory protection attributes corresponding to PE/COFF Image Retrieves the memory protection attributes corresponding to PE/COFF Image
@ -107,8 +323,8 @@ InternalInsertImageRecordSegmentPadding (
} }
UEFI_IMAGE_RECORD * UEFI_IMAGE_RECORD *
UefiImageLoaderGetImageRecordPeCoff ( UefiImageLoaderGetImageRecordPe (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
) )
{ {
UEFI_IMAGE_RECORD *ImageRecord; UEFI_IMAGE_RECORD *ImageRecord;
@ -135,7 +351,7 @@ UefiImageLoaderGetImageRecordPeCoff (
// Determine the maximum amount of Image record sections and allocate the // Determine the maximum amount of Image record sections and allocate the
// Image record. // Image record.
// //
NumberOfSections = PeCoffGetSectionTable (Context, &Sections); NumberOfSections = PeCoffGetSectionTable (&Context->Ctx.Pe, &Sections);
STATIC_ASSERT ( STATIC_ASSERT (
MAX_UINT16 <= MAX_UINT32 / 2 - 1, MAX_UINT16 <= MAX_UINT32 / 2 - 1,
@ -162,14 +378,13 @@ UefiImageLoaderGetImageRecordPeCoff (
+ MaxNumRecordSegments * sizeof (*ImageRecord->Segments) + MaxNumRecordSegments * sizeof (*ImageRecord->Segments)
); );
if (ImageRecord == NULL) { if (ImageRecord == NULL) {
DEBUG_RAISE ();
return NULL; return NULL;
} }
ImageRecord->Signature = UEFI_IMAGE_RECORD_SIGNATURE; ImageRecord->Signature = UEFI_IMAGE_RECORD_SIGNATURE;
InitializeListHead (&ImageRecord->Link); InitializeListHead (&ImageRecord->Link);
SectionAlignment = PeCoffGetSectionAlignment (Context); SectionAlignment = PeCoffGetSectionAlignment (&Context->Ctx.Pe);
// //
// Map the Image Headers as read-only data. If the first Image section is // Map the Image Headers as read-only data. If the first Image section is
// loaded at the start of the Image memory space, the condition // loaded at the start of the Image memory space, the condition
@ -177,7 +392,7 @@ UefiImageLoaderGetImageRecordPeCoff (
// ignored. // ignored.
// //
StartAddress = 0; StartAddress = 0;
EndAddress = PeCoffGetSizeOfHeaders (Context); EndAddress = PeCoffGetSizeOfHeaders (&Context->Ctx.Pe);
Characteristics = EFI_IMAGE_SCN_MEM_READ; Characteristics = EFI_IMAGE_SCN_MEM_READ;
Attributes = EFI_MEMORY_XP | EFI_MEMORY_RO; Attributes = EFI_MEMORY_XP | EFI_MEMORY_RO;
ASSERT (Attributes == InternalCharacteristicsToAttributes (Characteristics)); ASSERT (Attributes == InternalCharacteristicsToAttributes (Characteristics));
@ -268,8 +483,8 @@ UefiImageLoaderGetImageRecordPeCoff (
RecordSegment->Attributes = Attributes; RecordSegment->Attributes = Attributes;
++NumRecordSegments; ++NumRecordSegments;
ImageAddress = PeCoffLoaderGetImageAddress (Context); ImageAddress = PeCoffLoaderGetImageAddress (&Context->Ctx.Pe);
SizeOfImage = PeCoffGetSizeOfImage (Context); SizeOfImage = PeCoffGetSizeOfImage (&Context->Ctx.Pe);
// //
// The Image trailer, if existent, is treated as padding and as such is // The Image trailer, if existent, is treated as padding and as such is
// reported as read-only data, as intended. Because it is not part of the // reported as read-only data, as intended. Because it is not part of the
@ -318,14 +533,16 @@ InternalDebugLocateImage (
// //
// Search for the Image Header in 4 Byte steps. All dynamically loaded // Search for the Image Header in 4 Byte steps. All dynamically loaded
// Images start at a page boundary to allow for Image section protection, // Images start at a page boundary to allow for Image section protection,
// but XIP Images may not. // but XIP Images may not. As all Image Headers are at least 4 Byte aligned
// due to natural alignment, even XIP TE Image Headers should start at a
// 4 Byte boundary.
// //
// Do not attempt to access memory of the first page as it may be protected as // Do not attempt to access memory of the first page as it may be protected as
// part of NULL dereference detection. // part of NULL dereference detection.
// //
for (; EFI_PAGE_SIZE <= (UINTN) Buffer; Buffer -= 4) { for (; EFI_PAGE_SIZE <= (UINTN) Buffer; Buffer -= 4) {
// //
// Try to parse the current memory as PE/COFF Image. Pass MAX_UINT32 // Try to parse the current memory as PE/COFF or TE Image. Pass MAX_UINT32
// as the file size as there isn't any more information available. Only the // as the file size as there isn't any more information available. Only the
// Image Header memory will be accessed as part of initialisation. // Image Header memory will be accessed as part of initialisation.
// //
@ -362,6 +579,7 @@ InternalDebugLocateImage (
// //
// We know that (UINTN) Buffer <= Address from the initialisation. // We know that (UINTN) Buffer <= Address from the initialisation.
// //
// FIXME: Set to non-stripped base for XIP TE Images.
if (Address < (UINTN) Buffer + PeCoffGetSizeOfImage (Context)) { if (Address < (UINTN) Buffer + PeCoffGetSizeOfImage (Context)) {
Context->ImageBuffer = Buffer; Context->ImageBuffer = Buffer;
// //
@ -374,7 +592,7 @@ InternalDebugLocateImage (
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
// //
// Continue for the unlikely case that a PE/COFF Image embeds another // Continue for the unlikely case that a PE/COFF or TE Image embeds another
// one within its data, the outer Image may still follow. // one within its data, the outer Image may still follow.
// //
} }
@ -383,8 +601,8 @@ InternalDebugLocateImage (
} }
RETURN_STATUS RETURN_STATUS
UefiImageDebugLocateImagePeCoff ( UefiImageDebugLocateImagePe (
OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context, OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN UINTN Address IN UINTN Address
) )
{ {
@ -404,14 +622,15 @@ UefiImageDebugLocateImagePeCoff (
// the Image base to not access too much (potentially protected) memory. // the Image base to not access too much (potentially protected) memory.
// //
if (!PcdGetBool (PcdImageLoaderLoadHeader)) { if (!PcdGetBool (PcdImageLoaderLoadHeader)) {
DEBUG_RAISE ();
return RETURN_NOT_FOUND; return RETURN_NOT_FOUND;
} }
Context->FormatIndex = UefiImageFormatPe;
// //
// Align the search buffer to a 4 Byte boundary. // Align the search buffer to a 4 Byte boundary.
// //
Status = InternalDebugLocateImage ( Status = InternalDebugLocateImage (
Context, &Context->Ctx.Pe,
(CHAR8 *) (Address & ~(UINTN) 3U), (CHAR8 *) (Address & ~(UINTN) 3U),
Address, Address,
FALSE FALSE
@ -423,24 +642,27 @@ UefiImageDebugLocateImagePeCoff (
} }
RETURN_STATUS RETURN_STATUS
UefiImageGetFixedAddressPeCoff ( UefiImageGetFixedAddressPe (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context, IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT UINT64 *Address OUT UINT64 *Address
) )
{ {
UINT32 SectionAlignment;
CONST EFI_IMAGE_SECTION_HEADER *Sections; CONST EFI_IMAGE_SECTION_HEADER *Sections;
UINT16 NumberOfSections; UINT16 NumberOfSections;
UINT16 SectionIndex; UINT16 SectionIndex;
UINT64 FixedAddress; UINT64 FixedAddress;
ASSERT (Address != NULL); ASSERT (Address != NULL);
SectionAlignment = PeCoffGetSectionAlignment (&Context->Ctx.Pe);
// //
// If this feature is enabled, the build tool will save the address in the // If this feature is enabled, the build tool will save the address in the
// PointerToRelocations and PointerToLineNumbers fields of the first Image // PointerToRelocations and PointerToLineNumbers fields of the first Image
// section header that doesn't hold code. The 64-bit value across those fields // section header that doesn't hold code. The 64-bit value across those fields
// will be non-zero if and only if the module has been assigned an address. // will be non-zero if and only if the module has been assigned an address.
// //
NumberOfSections = PeCoffGetSectionTable (Context, &Sections); NumberOfSections = PeCoffGetSectionTable (&Context->Ctx.Pe, &Sections);
for (SectionIndex = 0; SectionIndex < NumberOfSections; ++SectionIndex) { for (SectionIndex = 0; SectionIndex < NumberOfSections; ++SectionIndex) {
if ((Sections[SectionIndex].Characteristics & EFI_IMAGE_SCN_CNT_CODE) != 0) { if ((Sections[SectionIndex].Characteristics & EFI_IMAGE_SCN_CNT_CODE) != 0) {
continue; continue;
@ -450,7 +672,7 @@ UefiImageGetFixedAddressPeCoff (
(CONST VOID *) &Sections[SectionIndex].PointerToRelocations (CONST VOID *) &Sections[SectionIndex].PointerToRelocations
); );
if (FixedAddress != 0) { if (FixedAddress != 0) {
if (!IS_ALIGNED (FixedAddress, Context->SectionAlignment)) { if (!IS_ALIGNED (FixedAddress, SectionAlignment)) {
return RETURN_UNSUPPORTED; return RETURN_UNSUPPORTED;
} }
@ -465,8 +687,8 @@ UefiImageGetFixedAddressPeCoff (
} }
VOID VOID
UefiImageDebugPrintSegmentsPeCoff ( UefiImageDebugPrintSegmentsPe (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
) )
{ {
CONST EFI_IMAGE_SECTION_HEADER *Sections; CONST EFI_IMAGE_SECTION_HEADER *Sections;
@ -474,30 +696,27 @@ UefiImageDebugPrintSegmentsPeCoff (
UINT16 SectionIndex; UINT16 SectionIndex;
CONST UINT8 *Name; CONST UINT8 *Name;
NumberOfSections = PeCoffGetSectionTable (Context, &Sections); NumberOfSections = PeCoffGetSectionTable (&Context->Ctx.Pe, &Sections);
for (SectionIndex = 0; SectionIndex < NumberOfSections; ++SectionIndex) { for (SectionIndex = 0; SectionIndex < NumberOfSections; ++SectionIndex) {
Name = Sections[SectionIndex].Name; Name = Sections[SectionIndex].Name;
DEBUG (( DEBUG ((
DEBUG_VERBOSE, DEBUG_VERBOSE,
" Section - '%c%c%c%c%c%c%c%c'\n" " Section - '%c%c%c%c%c%c%c%c'\n",
" VirtualSize - 0x%08x\n" " VirtualSize - 0x%08x\n"
" VirtualAddress - 0x%08x\n" " VirtualAddress - 0x%08x\n"
" SizeOfRawData - 0x%08x\n" " SizeOfRawData - 0x%08x\n"
" PointerToRawData - 0x%08x\n", " PointerToRawData - 0x%08x\n"
Name[0], Name[1], Name[2], Name[3], Name[4], Name[5], Name[6], Name[7],
Sections[SectionIndex].VirtualSize,
Sections[SectionIndex].VirtualAddress,
Sections[SectionIndex].SizeOfRawData,
Sections[SectionIndex].PointerToRawData
));
DEBUG ((
DEBUG_VERBOSE,
" PointerToRelocations - 0x%08x\n" " PointerToRelocations - 0x%08x\n"
" PointerToLinenumbers - 0x%08x\n" " PointerToLinenumbers - 0x%08x\n"
" NumberOfRelocations - 0x%08x\n" " NumberOfRelocations - 0x%08x\n"
" NumberOfLinenumbers - 0x%08x\n" " NumberOfLinenumbers - 0x%08x\n"
" Characteristics - 0x%08x\n", " Characteristics - 0x%08x\n",
Name[0], Name[1], Name[2], Name[3], Name[4], Name[5], Name[6], Name[7],
Sections[SectionIndex].VirtualSize,
Sections[SectionIndex].VirtualAddress,
Sections[SectionIndex].SizeOfRawData,
Sections[SectionIndex].PointerToRawData,
Sections[SectionIndex].PointerToRelocations, Sections[SectionIndex].PointerToRelocations,
Sections[SectionIndex].PointerToLinenumbers, Sections[SectionIndex].PointerToLinenumbers,
Sections[SectionIndex].NumberOfRelocations, Sections[SectionIndex].NumberOfRelocations,
@ -506,3 +725,33 @@ UefiImageDebugPrintSegmentsPeCoff (
)); ));
} }
} }
GLOBAL_REMOVE_IF_UNREFERENCED CONST UEFI_IMAGE_FORMAT_SUPPORT mPeSupport = {
UefiImageInitializeContextPreHashPe,
UefiImageHashImageDefaultPe,
UefiImageInitializeContextPostHashPe,
UefiImageLoadImagePe,
UefiImageImageIsInplacePe,
UefiImageLoadImageInplacePe,
UefiImageRelocateImageInplacePe,
UefiImageLoaderGetRuntimeContextSizePe,
UefiImageRelocateImagePe,
UefiImageRuntimeRelocateImagePe,
UefiImageDiscardSegmentsPe,
UefiImageGetSymbolsPathPe,
UefiImageGetFirstCertificatePe,
UefiImageGetNextCertificatePe,
UefiImageGetHiiDataRvaPe,
UefiImageGetEntryPointAddressPe,
UefiImageGetMachinePe,
UefiImageGetSubsystemPe,
UefiImageGetSegmentAlignmentPe,
UefiImageGetImageSizePe,
UefiImageGetBaseAddressPe,
UefiImageGetRelocsStrippedPe,
UefiImageLoaderGetImageAddressPe,
UefiImageLoaderGetImageRecordPe,
UefiImageDebugLocateImagePe,
UefiImageGetFixedAddressPe,
UefiImageDebugPrintSegmentsPe
};

View File

@ -0,0 +1,16 @@
/** @file
UEFI Image Loader library implementation for PE/COFF Images.
Copyright (c) 2021, Marvin Häuser. All rights reserved.<BR>
SPDX-License-Identifier: BSD-3-Clause
**/
#ifndef PE_SUPPORT_H
#define PE_SUPPORT_H
#include "UefiImageFormat.h"
extern CONST UEFI_IMAGE_FORMAT_SUPPORT mPeSupport;
#endif // PE_SUPPORT_H

View File

@ -0,0 +1,235 @@
/** @file
UEFI Image Loader library fornat support infrastructure.
Copyright (c) 2023, Marvin Häuser. All rights reserved.<BR>
SPDX-License-Identifier: BSD-3-Clause
**/
#ifndef UEFI_IMAGE_FORMAT_H
#define UEFI_IMAGE_FORMAT_H
#include <Base.h>
#include <Library/UefiImageLib.h>
typedef
RETURN_STATUS
(*UEFI_IMAGE_INITIALIZE_CONTEXT_PRE_HASH) (
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN CONST VOID *FileBuffer,
IN UINT32 FileSize
);
typedef
BOOLEAN
(*UEFI_IMAGE_HASH_IMAGE_DEFAULT) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN OUT VOID *HashContext,
IN UEFI_IMAGE_LOADER_HASH_UPDATE HashUpdate
);
typedef
RETURN_STATUS
(*UEFI_IMAGE_INITIALIZE_CONTEXT_POST_HASH) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
RETURN_STATUS
(*UEFI_IMAGE_LOAD_IMAGE) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT VOID *Destination,
IN UINT32 DestinationSize
);
typedef
BOOLEAN
(*UEFI_IMAGE_IMAGE_IS_IN_PLACE) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
RETURN_STATUS
(*UEFI_IMAGE_LOAD_IMAGE_INPLACE) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
RETURN_STATUS
(*UEFI_IMAGE_RELOCAE_IMAGE_INPLACE) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
RETURN_STATUS
(*UEFI_IMAGE_LOADER_GET_RUNTIME_CONTEXT_SIZE) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT UINT32 *Size
);
typedef
RETURN_STATUS
(*UEFI_IMAGE_RELOCARE_IMAGE) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN UINT64 BaseAddress,
OUT UEFI_IMAGE_LOADER_RUNTIME_CONTEXT *RuntimeContext OPTIONAL,
IN UINT32 RuntimeContextSize
);
typedef
RETURN_STATUS
(*UEFI_IMAGE_RUNTIME_RELOCATE_IMAGE) (
IN OUT VOID *Image,
IN UINT32 ImageSize,
IN UINT64 BaseAddress,
IN CONST VOID *RuntimeContext
);
typedef
VOID
(*UEFI_IMAGE_DISCARD_SEGMENTS) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
RETURN_STATUS
(*UEFI_IMAGE_GET_SYMBOLS_PATH) (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT CONST CHAR8 **SymbolsPath,
OUT UINT32 *SymbolsPathSize
);
typedef
RETURN_STATUS
(*UEFI_IMAGE_GET_FIRST_CERTIFICATE) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT CONST WIN_CERTIFICATE **Certificate
);
typedef
RETURN_STATUS
(*UEFI_IMAGE_GET_NEXT_CERTIFICATE) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN OUT CONST WIN_CERTIFICATE **Certificate
);
typedef
RETURN_STATUS
(*UEFI_IMAGE_GET_HII_DATA_RVA) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT UINT32 *HiiRva,
OUT UINT32 *HiiSize
);
typedef
UINT32
(*UEFI_IMAGE_GET_ENTRY_POINT_ADDRESS) (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
UINT16
(*UEFI_IMAGE_GET_MACHINE) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
UINT16
(*UEFI_IMAGE_GET_SUBSYSTEM) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
UINT32
(*UEFI_IMAGE_GET_SEGMENT_ALIGNMENT) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
UINT32
(*UEFI_IMAGE_GET_IMAGE_SIZE) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
UINT32
(*UEFI_IMAGE_GET_IMAGE_SIZE_INPLACE) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
UINT64
(*UEFI_IMAGE_GET_BASE_ADDRESS) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
BOOLEAN
(*UEFI_IMAGE_GET_RELOCS_STRIPPED) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
UINTN
(*UEFI_IMAGE_LOADER_GET_IMAGE_ADDRESS) (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
UEFI_IMAGE_RECORD *
(*UEFI_IMAGE_LOADER_GET_IMAGE_RECORD) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef
RETURN_STATUS
(*UEFI_IMAGE_DEBUG_LOCATE_IMAGE) (
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN UINTN Address
);
typedef
RETURN_STATUS
(*UEFI_IMAGE_GET_FIXED_ADDRESS) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT UINT64 *Address
);
typedef
VOID
(*UEFI_IMAGE_DEBUG_PRINT_SEGMENTS) (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef struct {
UEFI_IMAGE_INITIALIZE_CONTEXT_PRE_HASH InitializeContextPreHash;
UEFI_IMAGE_HASH_IMAGE_DEFAULT HashImageDefault;
UEFI_IMAGE_INITIALIZE_CONTEXT_POST_HASH InitializeContextPostHash;
UEFI_IMAGE_LOAD_IMAGE LoadImage;
UEFI_IMAGE_IMAGE_IS_IN_PLACE ImageIsInplace;
UEFI_IMAGE_LOAD_IMAGE_INPLACE LoadImageInplace;
UEFI_IMAGE_RELOCAE_IMAGE_INPLACE RelocateImageInplace;
UEFI_IMAGE_LOADER_GET_RUNTIME_CONTEXT_SIZE LoaderGetRuntimeContextSize;
UEFI_IMAGE_RELOCARE_IMAGE RelocateImage;
UEFI_IMAGE_RUNTIME_RELOCATE_IMAGE RuntimeRelocateImage;
UEFI_IMAGE_DISCARD_SEGMENTS DiscardSegments;
UEFI_IMAGE_GET_SYMBOLS_PATH GetSymbolsPath;
UEFI_IMAGE_GET_FIRST_CERTIFICATE GetFirstCertificate;
UEFI_IMAGE_GET_NEXT_CERTIFICATE GetNextCertificate;
UEFI_IMAGE_GET_HII_DATA_RVA GetHiiDataRva;
UEFI_IMAGE_GET_ENTRY_POINT_ADDRESS GetEntryPointAddress;
UEFI_IMAGE_GET_MACHINE GetMachine;
UEFI_IMAGE_GET_SUBSYSTEM GetSubsystem;
UEFI_IMAGE_GET_SEGMENT_ALIGNMENT GetSegmentAlignment;
UEFI_IMAGE_GET_IMAGE_SIZE GetImageSize;
UEFI_IMAGE_GET_BASE_ADDRESS GetBaseAddress;
UEFI_IMAGE_GET_RELOCS_STRIPPED GetRelocsStripped;
UEFI_IMAGE_LOADER_GET_IMAGE_ADDRESS LoaderGetImageAddress;
UEFI_IMAGE_LOADER_GET_IMAGE_RECORD LoaderGetImageRecord;
UEFI_IMAGE_DEBUG_LOCATE_IMAGE DebugLocateImage;
UEFI_IMAGE_GET_FIXED_ADDRESS GetFixedAddress;
UEFI_IMAGE_DEBUG_PRINT_SEGMENTS DebugPrintSegments;
} UEFI_IMAGE_FORMAT_SUPPORT;
#endif // UEFI_IMAGE_FORMAT_H

View File

@ -0,0 +1,629 @@
/** @file
UEFI Image Loader library implementation.
Copyright (c) 2023, Marvin Häuser. All rights reserved.<BR>
SPDX-License-Identifier: BSD-3-Clause
**/
#include <Base.h>
#include <Uefi/UefiBaseType.h>
#include <Uefi/UefiSpec.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BaseOverflowLib.h>
#include <Library/CacheMaintenanceLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiImageLib.h>
#include <Library/UefiImageExtraActionLib.h>
#include "PeSupport.h"
STATIC_ASSERT (
UEFI_IMAGE_FORMAT_SUPPORT_SOURCES != 0,
"At least one UEFI image format support source must be enabled."
);
#if (UEFI_IMAGE_FORMAT_SUPPORT_SOURCES & (1 << UEFI_IMAGE_SOURCE_NON_FV)) != 0
#define UEFI_IMAGE_FORMAT_SUPPORT_NON_FV PcdGet8 (PcdUefiImageFormatSupportNonFv)
#else
#define UEFI_IMAGE_FORMAT_SUPPORT_NON_FV 0
#endif
#if (UEFI_IMAGE_FORMAT_SUPPORT_SOURCES & (1 << UEFI_IMAGE_SOURCE_FV)) != 0
#define UEFI_IMAGE_FORMAT_SUPPORT_FV PcdGet8 (PcdUefiImageFormatSupportFv)
#else
#define UEFI_IMAGE_FORMAT_SUPPORT_FV 0
#endif
#define UEFI_IMAGE_SUPPORT \
(UEFI_IMAGE_FORMAT_SUPPORT_NON_FV | UEFI_IMAGE_FORMAT_SUPPORT_FV)
#define FORMAT_EQ(FormatIndex, Format) \
(UEFI_IMAGE_SUPPORT == (1U << (Format)) || \
((UEFI_IMAGE_SUPPORT & (1U << (Format))) != 0 && \
(FormatIndex) == (Format)))
#define UEFI_IMAGE_EXEC(Result, FormatIndex, Func, ...) \
do { \
ASSERT ((FormatIndex) == UefiImageFormatPe); \
Result = mPeSupport.Func (__VA_ARGS__); \
} while (FALSE)
#define UEFI_IMAGE_EXEC_VOID(FormatIndex, Func, ...) \
do { \
ASSERT ((FormatIndex) == UefiImageFormatPe); \
mPeSupport.Func (__VA_ARGS__); \
} while (FALSE)
STATIC_ASSERT (
UefiImageFormatPe == UefiImageFormatMax - 1,
"Support for more formats needs to be added above."
);
#define FORMAT_SUPPORTED(Format, Source) \
((UEFI_IMAGE_SUPPORT & (1U << (Format))) != 0 && \
(mUefiImageSupportSource[Source] & (1U << (Format))) != 0)
STATIC
RETURN_STATUS
InternalInitializeContextPreHash (
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN CONST VOID *FileBuffer,
IN UINT32 FileSize,
IN UINT8 FormatIndex
)
{
RETURN_STATUS Status;
UEFI_IMAGE_EXEC (
Status,
FormatIndex,
InitializeContextPreHash,
Context,
FileBuffer,
FileSize
);
return Status;
}
RETURN_STATUS
UefiImageInitializeContextPreHash (
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN CONST VOID *FileBuffer,
IN UINT32 FileSize,
IN UEFI_IMAGE_SOURCE Source
)
{
CONST UINT8 mUefiImageSupportSource[UEFI_IMAGE_SOURCE_MAX] = {
UEFI_IMAGE_FORMAT_SUPPORT_NON_FV,
UEFI_IMAGE_FORMAT_SUPPORT_FV,
UEFI_IMAGE_SUPPORT
};
RETURN_STATUS Status;
#if (UEFI_IMAGE_FORMAT_SUPPORT_SOURCES & (1U << UEFI_IMAGE_SOURCE_NON_FV)) != 0
ASSERT ((PcdGet8 (PcdUefiImageFormatSupportNonFv) & ~((1ULL << UefiImageFormatMax) - 1ULL)) == 0);
ASSERT (PcdGet8 (PcdUefiImageFormatSupportNonFv) != 0);
#else
ASSERT (Source != UEFI_IMAGE_SOURCE_NON_FV);
#endif
#if (UEFI_IMAGE_FORMAT_SUPPORT_SOURCES & (1U << UEFI_IMAGE_SOURCE_FV)) != 0
ASSERT ((PcdGet8 (PcdUefiImageFormatSupportFv) & ~((1ULL << UefiImageFormatMax) - 1ULL)) == 0);
ASSERT (PcdGet8 (PcdUefiImageFormatSupportFv) != 0);
#else
ASSERT (Source != UEFI_IMAGE_SOURCE_FV);
#endif
Status = RETURN_UNSUPPORTED;
STATIC_ASSERT (
UefiImageFormatPe == UefiImageFormatMax - 1,
"Support for more formats needs to be added above."
);
if (FORMAT_SUPPORTED (UefiImageFormatPe, Source)) {
Status = InternalInitializeContextPreHash (
Context,
FileBuffer,
FileSize,
UefiImageFormatPe
);
if (!RETURN_ERROR (Status)) {
Context->FormatIndex = UefiImageFormatPe;
return RETURN_SUCCESS;
}
}
return Status;
}
BOOLEAN
UefiImageHashImageDefault (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN OUT VOID *HashContext,
IN UEFI_IMAGE_LOADER_HASH_UPDATE HashUpdate
)
{
BOOLEAN Success;
UEFI_IMAGE_EXEC (
Success,
Context->FormatIndex,
HashImageDefault,
Context,
HashContext,
HashUpdate
);
return Success;
}
RETURN_STATUS
UefiImageInitializeContextPostHash (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
RETURN_STATUS Status;
UEFI_IMAGE_EXEC (
Status,
Context->FormatIndex,
InitializeContextPostHash,
Context
);
return Status;
}
RETURN_STATUS
UefiImageLoadImage (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT VOID *Destination,
IN UINT32 DestinationSize
)
{
RETURN_STATUS Status;
UEFI_IMAGE_EXEC (
Status,
Context->FormatIndex,
LoadImage,
Context,
Destination,
DestinationSize
);
return Status;
}
BOOLEAN
UefiImageImageIsInplace (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
BOOLEAN Result;
UEFI_IMAGE_EXEC (
Result,
Context->FormatIndex,
ImageIsInplace,
Context
);
return Result;
}
RETURN_STATUS
UefiImageLoadImageInplace (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
RETURN_STATUS Status;
UEFI_IMAGE_EXEC (
Status,
Context->FormatIndex,
LoadImageInplace,
Context
);
return Status;
}
RETURN_STATUS
UefiImageRelocateImageInplace (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
RETURN_STATUS Status;
UEFI_IMAGE_EXEC (
Status,
Context->FormatIndex,
RelocateImageInplace,
Context
);
return Status;
}
RETURN_STATUS
UefiImageLoaderGetRuntimeContextSize (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT UINT32 *Size
)
{
RETURN_STATUS Status;
UEFI_IMAGE_EXEC (
Status,
Context->FormatIndex,
LoaderGetRuntimeContextSize,
Context,
Size
);
if (!RETURN_ERROR (Status)) {
*Size += 8;
}
return Status;
}
RETURN_STATUS
UefiImageRelocateImage (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN UINT64 BaseAddress,
OUT UEFI_IMAGE_LOADER_RUNTIME_CONTEXT *RuntimeContext OPTIONAL,
IN UINT32 RuntimeContextSize
)
{
RETURN_STATUS Status;
if (RuntimeContext != NULL) {
*(UINT64 *)RuntimeContext = Context->FormatIndex;
RuntimeContext = (UEFI_IMAGE_LOADER_RUNTIME_CONTEXT *)((UINT64 *)RuntimeContext + 1);
ASSERT (RuntimeContextSize >= 8);
RuntimeContextSize -= 8;
}
UEFI_IMAGE_EXEC (
Status,
Context->FormatIndex,
RelocateImage,
Context,
BaseAddress,
RuntimeContext,
RuntimeContextSize
);
if (!RETURN_ERROR (Status)) {
UefiImageLoaderRelocateImageExtraAction (Context);
}
return Status;
}
RETURN_STATUS
UefiImageRuntimeRelocateImage (
IN OUT VOID *Image,
IN UINT32 ImageSize,
IN UINT64 BaseAddress,
IN CONST UEFI_IMAGE_LOADER_RUNTIME_CONTEXT *RuntimeContext
)
{
RETURN_STATUS Status;
UEFI_IMAGE_EXEC (
Status,
*(UINT8 *)RuntimeContext,
RuntimeRelocateImage,
Image,
ImageSize,
BaseAddress,
((UINT64 *)RuntimeContext + 1)
);
return Status;
}
VOID
UefiImageDiscardSegments (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
UEFI_IMAGE_EXEC_VOID (
Context->FormatIndex,
DiscardSegments,
Context
);
}
RETURN_STATUS
UefiImageGetSymbolsPath (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT CONST CHAR8 **SymbolsPath,
OUT UINT32 *SymbolsPathSize
)
{
RETURN_STATUS Status;
UEFI_IMAGE_EXEC (
Status,
Context->FormatIndex,
GetSymbolsPath,
Context,
SymbolsPath,
SymbolsPathSize
);
return Status;
}
RETURN_STATUS
UefiImageGetFirstCertificate (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT CONST WIN_CERTIFICATE **Certificate
)
{
RETURN_STATUS Status;
UEFI_IMAGE_EXEC (
Status,
Context->FormatIndex,
GetFirstCertificate,
Context,
Certificate
);
return Status;
}
RETURN_STATUS
UefiImageGetNextCertificate (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN OUT CONST WIN_CERTIFICATE **Certificate
)
{
RETURN_STATUS Status;
UEFI_IMAGE_EXEC (
Status,
Context->FormatIndex,
GetNextCertificate,
Context,
Certificate
);
return Status;
}
RETURN_STATUS
UefiImageGetHiiDataRva (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT UINT32 *HiiRva,
OUT UINT32 *HiiSize
)
{
RETURN_STATUS Status;
UEFI_IMAGE_EXEC (
Status,
Context->FormatIndex,
GetHiiDataRva,
Context,
HiiRva,
HiiSize
);
return Status;
}
UINT32
UefiImageGetEntryPointAddress (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
UINT32 Result;
UEFI_IMAGE_EXEC (
Result,
Context->FormatIndex,
GetEntryPointAddress,
Context
);
return Result;
}
UINT16
UefiImageGetMachine (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
UINT16 Result;
UEFI_IMAGE_EXEC (
Result,
Context->FormatIndex,
GetMachine,
Context
);
return Result;
}
UINT16
UefiImageGetSubsystem (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
UINT16 Result;
UEFI_IMAGE_EXEC (
Result,
Context->FormatIndex,
GetSubsystem,
Context
);
return Result;
}
UINT32
UefiImageGetSegmentAlignment (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
UINT32 Result;
UEFI_IMAGE_EXEC (
Result,
Context->FormatIndex,
GetSegmentAlignment,
Context
);
return Result;
}
UINT32
UefiImageGetImageSize (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
UINT32 Result;
UEFI_IMAGE_EXEC (
Result,
Context->FormatIndex,
GetImageSize,
Context
);
return Result;
}
UINT64
UefiImageGetBaseAddress (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
UINT64 Result;
UEFI_IMAGE_EXEC (
Result,
Context->FormatIndex,
GetBaseAddress,
Context
);
return Result;
}
BOOLEAN
UefiImageGetRelocsStripped (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
BOOLEAN Result;
UEFI_IMAGE_EXEC (
Result,
Context->FormatIndex,
GetRelocsStripped,
Context
);
return Result;
}
UINTN
UefiImageLoaderGetImageAddress (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
UINTN Result;
UEFI_IMAGE_EXEC (
Result,
Context->FormatIndex,
LoaderGetImageAddress,
Context
);
return Result;
}
UEFI_IMAGE_RECORD *
UefiImageLoaderGetImageRecord (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
UEFI_IMAGE_RECORD *Result;
UEFI_IMAGE_EXEC (
Result,
Context->FormatIndex,
LoaderGetImageRecord,
Context
);
return Result;
}
RETURN_STATUS
UefiImageDebugLocateImage (
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN UINTN Address
)
{
RETURN_STATUS Status;
UEFI_IMAGE_EXEC (
Status,
Context->FormatIndex,
DebugLocateImage,
Context,
Address
);
return Status;
}
RETURN_STATUS
UefiImageGetFixedAddress (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT UINT64 *Address
)
{
RETURN_STATUS Status;
UEFI_IMAGE_EXEC (
Status,
Context->FormatIndex,
GetFixedAddress,
Context,
Address
);
return Status;
}
VOID
UefiImageDebugPrintSegments (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
UEFI_IMAGE_EXEC_VOID (
Context->FormatIndex,
DebugPrintSegments,
Context
);
}

View File

@ -1,299 +0,0 @@
/** @file
UEFI Image Loader library implementation for PE/COFF Images.
Copyright (c) 2021, Marvin Häuser. All rights reserved.<BR>
SPDX-License-Identifier: BSD-3-Clause
**/
#define UEFI_IMAGE_LOADER_IMAGE_CONTEXT PE_COFF_LOADER_IMAGE_CONTEXT
#define UEFI_IMAGE_LOADER_RUNTIME_CONTEXT PE_COFF_LOADER_RUNTIME_CONTEXT
#include <Base.h>
#include <Uefi/UefiBaseType.h>
#include <Uefi/UefiSpec.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BaseOverflowLib.h>
#include <Library/CacheMaintenanceLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/PeCoffLib2.h>
#include <Library/UefiImageLib.h>
#include <Library/UefiImageExtraActionLib.h>
#include "PeCoffSupport.h"
RETURN_STATUS
UefiImageInitializeContextPreHash (
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN CONST VOID *FileBuffer,
IN UINT32 FileSize
)
{
return PeCoffInitializeContext (Context, FileBuffer, FileSize);
}
RETURN_STATUS
UefiImageInitializeContextPostHash (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
ASSERT (Context != NULL);
return RETURN_SUCCESS;
}
UINT8
UefiImageGetFormat (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return UefiImageFormatPe;
}
BOOLEAN
UefiImageHashImageDefault (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN OUT VOID *HashContext,
IN UEFI_IMAGE_LOADER_HASH_UPDATE HashUpdate
)
{
return PeCoffHashImageAuthenticode (Context, HashContext, HashUpdate);
}
RETURN_STATUS
UefiImageLoadImage (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT VOID *Destination,
IN UINT32 DestinationSize
)
{
return PeCoffLoadImage (Context, Destination, DestinationSize);
}
BOOLEAN
UefiImageImageIsInplace (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffImageIsInplace (Context);
}
RETURN_STATUS
UefiImageLoadImageInplace (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffLoadImageInplace (Context);
}
RETURN_STATUS
UefiImageRelocateImageInplace (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffRelocateImageInplace (Context);
}
RETURN_STATUS
UefiImageLoaderGetRuntimeContextSize (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT UINT32 *Size
)
{
return PeCoffLoaderGetRuntimeContextSize (Context, Size);
}
RETURN_STATUS
UefiImageRelocateImage (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN UINT64 BaseAddress,
OUT UEFI_IMAGE_LOADER_RUNTIME_CONTEXT *RuntimeContext OPTIONAL,
IN UINT32 RuntimeContextSize
)
{
RETURN_STATUS Status;
Status = PeCoffRelocateImage (
Context,
BaseAddress,
RuntimeContext,
RuntimeContextSize
);
if (!RETURN_ERROR (Status)) {
UefiImageLoaderRelocateImageExtraAction (Context);
}
return Status;
}
RETURN_STATUS
UefiImageRuntimeRelocateImage (
IN OUT VOID *Image,
IN UINT32 ImageSize,
IN UINT64 BaseAddress,
IN CONST UEFI_IMAGE_LOADER_RUNTIME_CONTEXT *RuntimeContext
)
{
return PeCoffRuntimeRelocateImage (
Image,
ImageSize,
BaseAddress,
RuntimeContext
);
}
VOID
UefiImageDiscardSegments (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
PeCoffDiscardSections (Context);
}
RETURN_STATUS
UefiImageGetSymbolsPath (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT CONST CHAR8 **SymbolsPath,
OUT UINT32 *SymbolsPathSize
)
{
return PeCoffGetPdbPath (Context, SymbolsPath, SymbolsPathSize);
}
RETURN_STATUS
UefiImageGetFirstCertificate (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT CONST WIN_CERTIFICATE **Certificate
)
{
return PeCoffGetFirstCertificate (Context, Certificate);
}
RETURN_STATUS
UefiImageGetNextCertificate (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN OUT CONST WIN_CERTIFICATE **Certificate
)
{
return PeCoffGetNextCertificate (Context, Certificate);
}
RETURN_STATUS
UefiImageGetHiiDataRva (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT UINT32 *HiiRva,
OUT UINT32 *HiiSize
)
{
return PeCoffGetHiiDataRva (Context, HiiRva, HiiSize);
}
UINT32
UefiImageGetEntryPointAddress (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetAddressOfEntryPoint (Context);
}
UINT16
UefiImageGetMachine (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetMachine (Context);
}
UINT16
UefiImageGetSubsystem (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetSubsystem (Context);
}
UINT32
UefiImageGetSegmentAlignment (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetSectionAlignment (Context);
}
UINT32
UefiImageGetImageSize (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetSizeOfImage (Context);
}
UINT32
UefiImageGetImageSizeInplace (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetSizeOfImageInplace (Context);
}
UINT64
UefiImageGetPreferredAddress (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetImageBase (Context);
}
BOOLEAN
UefiImageGetRelocsStripped (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffGetRelocsStripped (Context);
}
UINTN
UefiImageLoaderGetImageAddress (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffLoaderGetImageAddress (Context);
}
UEFI_IMAGE_RECORD *
UefiImageLoaderGetImageRecord (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return UefiImageLoaderGetImageRecordPeCoff (Context);
}
RETURN_STATUS
UefiImageDebugLocateImage (
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
IN UINTN Address
)
{
return UefiImageDebugLocateImagePeCoff (Context, Address);
}
RETURN_STATUS
UefiImageGetFixedAddress (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context,
OUT UINT64 *Address
)
{
return UefiImageGetFixedAddressPeCoff (Context, Address);
}
VOID
UefiImageDebugPrintSegments (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
UefiImageDebugPrintSegmentsPeCoff (Context);
}

View File

@ -23,3 +23,36 @@
MemoryProfileLib|MdeModulePkg/Library/BaseMemoryProfileLibNull/BaseMemoryProfileLibNull.inf MemoryProfileLib|MdeModulePkg/Library/BaseMemoryProfileLibNull/BaseMemoryProfileLibNull.inf
CommonMemoryAllocationLib|MdeModulePkg/Library/CommonMemoryAllocationLib/CommonMemoryAllocationLib.inf CommonMemoryAllocationLib|MdeModulePkg/Library/CommonMemoryAllocationLib/CommonMemoryAllocationLib.inf
#
# For security and code size optimization reasons, the UefiImageLib design is
# complicated. To not expose FV-only UEFI image formats via, e.g., DxeCore to
# untrusted sources, UefiImageLib can be configured to support different UEFI
# image formats per source. While compilers generally manage to optimize the
# initial parsing steps, complex control flow can make them lose track of the
# UefiImageLib source property and thus conditionally call into code for UEFI
# image formats that are not required by the module at all (e.g., because it
# only ever deals with FV images).
#
# To have the code for unsupported UEFI image file formats removed,
# UefiImageLib comes in multiple flavours that support FV-only, non-FV-only,
# or all UEFI image formats. These flavours are supposed to be used by
# top-level modules that have a clear scope. As libraries may depend on
# UefiImageLib too, however, they should consume the general UefiImageLib with
# no clear flavour.
#
# If they consume libraries with UefiImageLib dependencies, modules must have
# their general UefiImageLib set to their corresponding flavour for correct
# linkage. In order to make this easier, there is a heuristic below, based on
# module types, to set the most likely instance of UefiImageLib. In rare
# cases, manual overriding in the platform DSC may be necessary.
#
UefiImageOnlyNonFvLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageOnlyNonFvLib.inf
UefiImageOnlyFvLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageOnlyFvLib.inf
UefiImageAllLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageAllLib.inf
[LibraryClasses.common.USER_DEFINED, LibraryClasses.common.SEC, LibraryClasses.common.PEI_CORE, LibraryClasses.common.PEIM, LibraryClasses.common.SMM_CORE, LibraryClasses.common.MM_CORE_STANDALONE, LibraryClasses.common.DXE_SMM_DRIVER, LibraryClasses.common.MM_STANDALONE]
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageOnlyFvLib.inf
[LibraryClasses.common.DXE_CORE, LibraryClasses.common.DXE_DRIVER, LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION]
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageAllLib.inf

View File

@ -2311,6 +2311,16 @@
# @Prompt Remove X permission from WX sections. # @Prompt Remove X permission from WX sections.
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderRemoveXForWX|FALSE|BOOLEAN|0x40001021 gEfiMdePkgTokenSpaceGuid.PcdImageLoaderRemoveXForWX|FALSE|BOOLEAN|0x40001021
## Indicates the UEFI image file formats supported outside FVs.<BR><BR>
# BIT0 - PE.<BR>
# @Prompt Supported UEFI image file formats outside FVs.
gEfiMdePkgTokenSpaceGuid.PcdUefiImageFormatSupportNonFv|0x01|UINT8|0x40002000
## Indicates the UEFI image file formats supported inside FVs.<BR><BR>
# BIT0 - PE.<BR>
# @Prompt Supported UEFI image file formats inside FVs.
gEfiMdePkgTokenSpaceGuid.PcdUefiImageFormatSupportFv|0x01|UINT8|0x40002001
[PcdsFixedAtBuild,PcdsPatchableInModule] [PcdsFixedAtBuild,PcdsPatchableInModule]
## Indicates the maximum length of unicode string used in the following ## Indicates the maximum length of unicode string used in the following
# BaseLib functions: StrLen(), StrSize(), StrCmp(), StrnCmp(), StrCpy(), StrnCpy()<BR><BR> # BaseLib functions: StrLen(), StrSize(), StrCmp(), StrnCmp(), StrCpy(), StrnCpy()<BR><BR>

View File

@ -59,7 +59,9 @@
MdePkg/Library/BaseS3PciSegmentLib/BaseS3PciSegmentLib.inf MdePkg/Library/BaseS3PciSegmentLib/BaseS3PciSegmentLib.inf
MdePkg/Library/BaseArmTrngLibNull/BaseArmTrngLibNull.inf MdePkg/Library/BaseArmTrngLibNull/BaseArmTrngLibNull.inf
MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf MdePkg/Library/BaseUefiImageLib/BaseUefiImageOnlyNonFvLib.inf
MdePkg/Library/BaseUefiImageLib/BaseUefiImageOnlyFvLib.inf
MdePkg/Library/BaseUefiImageLib/BaseUefiImageAllLib.inf
MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf
MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
MdePkg/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf MdePkg/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf

View File

@ -47,7 +47,6 @@
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf

View File

@ -123,7 +123,6 @@
CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
@ -246,7 +245,6 @@
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
!endif !endif
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
[LibraryClasses.common.PEIM] [LibraryClasses.common.PEIM]
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
@ -262,7 +260,6 @@
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
!endif !endif
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
!if $(SOURCE_DEBUG_ENABLE) == TRUE !if $(SOURCE_DEBUG_ENABLE) == TRUE

View File

@ -129,7 +129,6 @@
CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
@ -270,7 +269,6 @@
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
!endif !endif
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
[LibraryClasses.common.PEIM] [LibraryClasses.common.PEIM]
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
@ -286,7 +284,6 @@
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
!endif !endif
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
!if $(SOURCE_DEBUG_ENABLE) == TRUE !if $(SOURCE_DEBUG_ENABLE) == TRUE

View File

@ -133,7 +133,6 @@
CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
@ -277,7 +276,6 @@
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
!endif !endif
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
[LibraryClasses.common.PEIM] [LibraryClasses.common.PEIM]
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
@ -293,7 +291,6 @@
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
!endif !endif
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
!if $(SOURCE_DEBUG_ENABLE) == TRUE !if $(SOURCE_DEBUG_ENABLE) == TRUE

View File

@ -138,7 +138,6 @@
CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
@ -283,7 +282,6 @@
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
!endif !endif
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
[LibraryClasses.common.PEIM] [LibraryClasses.common.PEIM]
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
@ -299,7 +297,6 @@
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
!endif !endif
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
!if $(SOURCE_DEBUG_ENABLE) == TRUE !if $(SOURCE_DEBUG_ENABLE) == TRUE

View File

@ -150,7 +150,6 @@
CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
@ -300,7 +299,6 @@
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
!endif !endif
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
CcProbeLib|OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.inf CcProbeLib|OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.inf
[LibraryClasses.common.PEIM] [LibraryClasses.common.PEIM]
@ -317,7 +315,6 @@
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
!endif !endif
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
!if $(SOURCE_DEBUG_ENABLE) == TRUE !if $(SOURCE_DEBUG_ENABLE) == TRUE

View File

@ -130,7 +130,6 @@
CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
@ -264,7 +263,6 @@
ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
[LibraryClasses.common.PEIM] [LibraryClasses.common.PEIM]
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
@ -275,7 +273,6 @@
ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
!if $(SOURCE_DEBUG_ENABLE) == TRUE !if $(SOURCE_DEBUG_ENABLE) == TRUE

View File

@ -722,7 +722,12 @@ FindAndReportEntryPoints (
// //
// Report SEC Core debug information when remote debug is enabled // Report SEC Core debug information when remote debug is enabled
// //
Status = UefiImageInitializeContext (&ImageContext, (VOID *) (UINTN) SecCoreImageBase, SecCoreImageSize); Status = UefiImageInitializeContext (
&ImageContext,
(VOID *) (UINTN) SecCoreImageBase,
SecCoreImageSize,
UEFI_IMAGE_SOURCE_FV
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = UefiImageLoadImageInplace (&ImageContext); Status = UefiImageLoadImageInplace (&ImageContext);
@ -733,7 +738,12 @@ FindAndReportEntryPoints (
// //
// Find PEI Core entry point // Find PEI Core entry point
// //
Status = UefiImageInitializeContext (&ImageContext, (VOID *) (UINTN) PeiCoreImageBase, PeiCoreImageSize); Status = UefiImageInitializeContext (
&ImageContext,
(VOID *) (UINTN) PeiCoreImageBase,
PeiCoreImageSize,
UEFI_IMAGE_SOURCE_FV
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = UefiImageLoadImageInplace (&ImageContext); Status = UefiImageLoadImageInplace (&ImageContext);

View File

@ -47,7 +47,7 @@
CpuLib CpuLib
DebugAgentLib DebugAgentLib
IoLib IoLib
UefiImageLib UefiImageOnlyFvLib
UefiImageExtraActionLib UefiImageExtraActionLib
ExtractGuidedSectionLib ExtractGuidedSectionLib
LocalApicLib LocalApicLib

View File

@ -33,7 +33,6 @@
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf
# FIXME: ARM? # FIXME: ARM?
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf

View File

@ -62,7 +62,8 @@ MeasureUefiImageAndExtend (
Status = UefiImageInitializeContextPreHash ( Status = UefiImageInitializeContextPreHash (
&ImageContext, &ImageContext,
(VOID *) (UINTN) ImageAddress, (VOID *) (UINTN) ImageAddress,
(UINT32) ImageSize (UINT32) ImageSize,
UEFI_IMAGE_SOURCE_ALL
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //

View File

@ -63,7 +63,7 @@
PerformanceLib PerformanceLib
ReportStatusCodeLib ReportStatusCodeLib
Tcg2PhysicalPresenceLib Tcg2PhysicalPresenceLib
UefiImageLib UefiImageAllLib
[Guids] [Guids]
## SOMETIMES_CONSUMES ## Variable:L"SecureBoot" ## SOMETIMES_CONSUMES ## Variable:L"SecureBoot"

View File

@ -53,7 +53,7 @@
PlatformSecureLib PlatformSecureLib
DevicePathLib DevicePathLib
FileExplorerLib FileExplorerLib
UefiImageLib UefiImageOnlyNonFvLib
SecureBootVariableLib SecureBootVariableLib
SecureBootVariableProvisionLib SecureBootVariableProvisionLib

View File

@ -1976,7 +1976,15 @@ EnrollImageSignatureToSigDB (
goto ON_EXIT; goto ON_EXIT;
} }
Status = UefiImageInitializeContextPreHash (&ImageContext, ImageBase, (UINT32)ImageSize); //
// Secure Boot does not apply to images from FVs.
//
Status = UefiImageInitializeContextPreHash (
&ImageContext,
ImageBase,
(UINT32)ImageSize,
UEFI_IMAGE_SOURCE_NON_FV
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }

View File

@ -41,7 +41,6 @@
PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
# #
# UEFI & PI # UEFI & PI

View File

@ -197,7 +197,12 @@ MmLoadImage (
// //
// Get information about the image being loaded // Get information about the image being loaded
// //
Status = UefiImageInitializeContext (&ImageContext, DriverEntry->Pe32Data, DriverEntry->Pe32DataSize); Status = UefiImageInitializeContext (
&ImageContext,
DriverEntry->Pe32Data,
DriverEntry->Pe32DataSize,
UEFI_IMAGE_SOURCE_FV
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }

View File

@ -49,7 +49,7 @@
HobLib HobLib
MemoryAllocationLib MemoryAllocationLib
MemLib MemLib
UefiImageLib UefiImageOnlyFvLib
ReportStatusCodeLib ReportStatusCodeLib
StandaloneMmProtectionLib StandaloneMmProtectionLib
StandaloneMmCoreEntryPoint StandaloneMmCoreEntryPoint

View File

@ -374,7 +374,12 @@ _ModuleEntryPoint (
DEBUG ((DEBUG_INFO, "Found Standalone MM PE data - 0x%x\n", TeData)); DEBUG ((DEBUG_INFO, "Found Standalone MM PE data - 0x%x\n", TeData));
// Obtain the PE/COFF Section information for the Standalone MM core module // Obtain the PE/COFF Section information for the Standalone MM core module
Status = UefiImageInitializeContext (&ImageContext, TeData, TeDataSize); Status = UefiImageInitializeContext (
&ImageContext,
TeData,
TeDataSize,
UEFI_IMAGE_SOURCE_FV
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM Core PE-COFF Section information - %r\n", Status)); DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM Core PE-COFF Section information - %r\n", Status));

View File

@ -54,7 +54,6 @@
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
StandaloneMmCoreEntryPoint|StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf StandaloneMmCoreEntryPoint|StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf

View File

@ -172,7 +172,8 @@ FindAndReportEntryPoints (
Status = UefiImageInitializeContext ( Status = UefiImageInitializeContext (
&ImageContext, &ImageContext,
(VOID*) (UINTN) SecCoreImageBase, (VOID*) (UINTN) SecCoreImageBase,
SecCoreImageSize SecCoreImageSize,
UEFI_IMAGE_SOURCE_FV
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
@ -198,7 +199,8 @@ FindAndReportEntryPoints (
Status = UefiImageInitializeContext ( Status = UefiImageInitializeContext (
&ImageContext, &ImageContext,
(VOID*)(UINTN)PeiCoreImageBase, (VOID*)(UINTN)PeiCoreImageBase,
PeiCoreImageSize PeiCoreImageSize,
UEFI_IMAGE_SOURCE_FV
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);

View File

@ -45,7 +45,7 @@
PcdLib PcdLib
DebugAgentLib DebugAgentLib
CpuLib CpuLib
UefiImageLib UefiImageOnlyFvLib
UefiImageExtraActionLib UefiImageExtraActionLib
CpuExceptionHandlerLib CpuExceptionHandlerLib
ReportStatusCodeLib ReportStatusCodeLib

View File

@ -58,7 +58,6 @@
SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
CcExitLib|UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf CcExitLib|UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf

View File

@ -36,7 +36,12 @@ LoadUefiImage (
UINT32 BufferSize; UINT32 BufferSize;
VOID *Buffer; VOID *Buffer;
Status = UefiImageInitializeContext (&ImageContext, UefiImage, UefiImageSize); Status = UefiImageInitializeContext (
&ImageContext,
UefiImage,
UefiImageSize,
UEFI_IMAGE_SOURCE_FV
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return Status; return Status;

View File

@ -51,7 +51,7 @@
IoLib IoLib
BlParseLib BlParseLib
HobLib HobLib
UefiImageLib UefiImageOnlyFvLib
PlatformSupportLib PlatformSupportLib
CpuLib CpuLib
MemoryAllocationLib MemoryAllocationLib

View File

@ -51,7 +51,7 @@
IoLib IoLib
HobLib HobLib
CpuLib CpuLib
UefiImageLib UefiImageOnlyFvLib
MemoryAllocationLib MemoryAllocationLib
[Guids] [Guids]

View File

@ -204,7 +204,6 @@
PciSegmentLib|MdePkg/Library/PciSegmentLibSegmentInfo/BasePciSegmentLibSegmentInfo.inf PciSegmentLib|MdePkg/Library/PciSegmentLibSegmentInfo/BasePciSegmentLibSegmentInfo.inf
PciSegmentInfoLib|UefiPayloadPkg/Library/PciSegmentInfoLibAcpiBoardInfo/PciSegmentInfoLibAcpiBoardInfo.inf PciSegmentInfoLib|UefiPayloadPkg/Library/PciSegmentInfoLibAcpiBoardInfo/PciSegmentInfoLibAcpiBoardInfo.inf
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
DxeHobListLib|UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf DxeHobListLib|UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf