Fixed bugs found when this code was ported into R8.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1240 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
ajfish 2006-08-11 18:04:56 +00:00
parent b48e3710a5
commit 317f832ef8
1 changed files with 7 additions and 5 deletions

View File

@ -610,7 +610,7 @@ PeCoffLoaderRelocateImage (
}
} else {
Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);
Adjust = (UINT64) (BaseAddress - Hdr.Te->ImageBase);
Adjust = (UINT64) (BaseAddress - Hdr.Te->ImageBase);
Hdr.Te->ImageBase = (UINT64) (BaseAddress);
//
@ -1200,13 +1200,13 @@ PeCoffLoaderRelocateImageForRuntime (
// Use PE32 offset
//
NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[0]);
} else {
//
// Use PE32+ offset
//
NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[0]);
}
//
@ -1258,7 +1258,7 @@ PeCoffLoaderRelocateImageForRuntime (
case EFI_IMAGE_REL_BASED_HIGH:
F16 = (UINT16 *) Fixup;
if (*(UINT16 *) FixupData == *F16) {
*F16 = (UINT16) ((*F16 << 16) + ((UINT16) Adjust & 0xffff));
*F16 = (UINT16) (*F16 + ((UINT16)(Adjust >> 16)));
}
FixupData = FixupData + sizeof (UINT16);
@ -1286,9 +1286,11 @@ PeCoffLoaderRelocateImageForRuntime (
case EFI_IMAGE_REL_BASED_DIR64:
F64 = (UINT64 *)Fixup;
FixupData = ALIGN_POINTER (FixupData, sizeof (UINT64));
if (*(UINT32 *) FixupData == *F64) {
if (*(UINT64 *) FixupData == *F64) {
*F64 = *F64 + (UINT64)Adjust;
}
FixupData = FixupData + sizeof (UINT64);
break;
case EFI_IMAGE_REL_BASED_HIGHADJ: