Correct ECC Error for MdePkg/Include/Protocol and Correct PeCofferLib bug to set ImageContext->EntryPoint after relocate when the destination address is specified.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5514 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4
2008-07-17 08:45:10 +00:00
parent 2a958a00c6
commit 19bee90c32
7 changed files with 42 additions and 76 deletions

View File

@@ -544,11 +544,8 @@ PeCoffLoaderRelocateImage (
//
if (ImageContext->DestinationAddress != 0) {
BaseAddress = ImageContext->DestinationAddress;
} else if (!(ImageContext->IsTeImage)) {
BaseAddress = ImageContext->ImageAddress;
} else {
Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);
BaseAddress = ImageContext->ImageAddress + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;
BaseAddress = ImageContext->ImageAddress;
}
if (!(ImageContext->IsTeImage)) {
@@ -597,8 +594,8 @@ PeCoffLoaderRelocateImage (
}
} else {
Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);
Adjust = (UINT64) (BaseAddress - Hdr.Te->ImageBase);
Hdr.Te->ImageBase = (UINT64) (BaseAddress);
Adjust = (UINT64) (BaseAddress - Hdr.Te->StrippedSize + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->ImageBase);
Hdr.Te->ImageBase = (UINT64) (BaseAddress - Hdr.Te->StrippedSize + sizeof (EFI_TE_IMAGE_HEADER));
//
// Find the relocation block
@@ -711,6 +708,13 @@ PeCoffLoaderRelocateImage (
RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;
}
//
// Adjust the EntryPoint to match the linked-to address
//
if (ImageContext->DestinationAddress != 0) {
ImageContext->EntryPoint -= (UINT64) ImageContext->ImageAddress;
ImageContext->EntryPoint += (UINT64) ImageContext->DestinationAddress;
}
return RETURN_SUCCESS;
}