diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-07-17 08:45:10 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-07-17 08:45:10 +0000 |
commit | 19bee90c32772dd225332193858d9c2fcd2930aa (patch) | |
tree | e845afafa13825eaca06d6a3ea51fea78aaa4968 /MdePkg/Library | |
parent | 2a958a00c62ea62c271fb1afc339fc735893460b (diff) | |
download | edk2-platforms-19bee90c32772dd225332193858d9c2fcd2930aa.tar.xz |
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
Diffstat (limited to 'MdePkg/Library')
-rw-r--r-- | MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c index 6d06c7e2a6..d46178dd25 100644 --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c @@ -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;
}
|