summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2016-02-29 17:08:45 +0100
committerArd Biesheuvel <ard.biesheuvel@linaro.org>2016-03-01 10:15:59 +0100
commit1cf4e9339de98a2a2a2b803f142993d776d9203d (patch)
treefe814d2d413a78d174c0772ce84b165a33028bc0 /MdeModulePkg/Core
parent48d97c8b5814e47ede7bf3a24a0f6c525439b27e (diff)
downloadedk2-platforms-1cf4e9339de98a2a2a2b803f142993d776d9203d.tar.xz
MdeModulePkg: DxeCore: fully initialize image context before passing it on
When the DXE core is loaded, it invokes the PeCoffExtraActionLib library function 'PeCoffLoaderRelocateImageExtraAction' explicitly, which may be in addition to the same function having been called by the DxeIpl PE/COFF loader instance. The ImageContext that DXE core presents to this function is only partially initialized, which may result in the following output on AArch64 systems: add-symbol-file ..MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.dll 0x5F226240 <some intermediate output> add-symbol-file ..MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.dll 0x5F226000 This is caused by incorrect data in the ImageContext structure, which means the start of the .text section is calculated incorrectly. In general, it is the duty of the caller to present a valid ImageContext structure, so let's add the missing values before invoking PeCoffLoaderRelocateImageExtraAction(). Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Star Zeng <star.zeng@intel.com>
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r--MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
index 0a34711b22..20ff02f663 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
+++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
@@ -247,6 +247,7 @@ DxeMain (
EFI_HOB_GUID_TYPE *GuidHob;
EFI_VECTOR_HANDOFF_INFO *VectorInfoList;
EFI_VECTOR_HANDOFF_INFO *VectorInfo;
+ VOID *EntryPoint;
//
// Setup the default exception handlers
@@ -293,8 +294,13 @@ DxeMain (
// Report DXE Core image information to the PE/COFF Extra Action Library
//
ZeroMem (&ImageContext, sizeof (ImageContext));
- ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)gDxeCoreLoadedImage->ImageBase;
- ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress);
+ ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)gDxeCoreLoadedImage->ImageBase;
+ ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*)(UINTN)ImageContext.ImageAddress);
+ ImageContext.SizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID*)(UINTN)ImageContext.ImageAddress);
+ Status = PeCoffLoaderGetEntryPoint ((VOID*)(UINTN)ImageContext.ImageAddress, &EntryPoint);
+ if (Status == EFI_SUCCESS) {
+ ImageContext.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)EntryPoint;
+ }
PeCoffLoaderRelocateImageExtraAction (&ImageContext);
//