Message ID | 1456762578-18459-1-git-send-email-ard.biesheuvel@linaro.org |
---|---|
State | Accepted |
Commit | 1cf4e9339de98a2a2a2b803f142993d776d9203d |
Headers | show |
On 1 March 2016 at 03:05, Zeng, Star <star.zeng@intel.com> wrote: > On 2016/3/1 0:16, Ard Biesheuvel wrote: >> >> 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> >> --- >> MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 10 ++++++++-- >> 1 file changed, 8 insertions(+), 2 deletions(-) > > > Reviewed-by: Star Zeng <star.zeng@intel.com> > Thanks. Committed as 1cf4e9339de9 > >> >> diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c >> b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c >> index 0a34711b22a4..20ff02f663b2 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); >> >> // >> > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c index 0a34711b22a4..20ff02f663b2 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); //
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> --- MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- 2.5.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel