Add one judge whether TeImage or PeImage has reloc section when relocate TeImage or PeImage into memory.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4224 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4 2007-10-26 09:28:29 +00:00
parent a72eca8459
commit 9626a87e43
2 changed files with 9 additions and 0 deletions

View File

@ -238,6 +238,13 @@ Returns:
return Status;
}
//
// When Image has no reloc section, it can't be relocated into memory.
//
if (ImageContext.RelocationsStripped) {
DEBUG ((EFI_D_ERROR, "The image at 0x%08x without reloc section can't be loaded into memory", (UINTN) Pe32Data));
return EFI_INVALID_PARAMETER;
}
//
// Allocate Memory for the image
//
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) AllocatePages (EFI_SIZE_TO_PAGES ((UINT32) ImageContext.ImageSize));

View File

@ -271,6 +271,8 @@ PeCoffLoaderGetImageInfo (
//
if ((!(ImageContext->IsTeImage)) && ((Hdr.Pe32->FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0)) {
ImageContext->RelocationsStripped = TRUE;
} else if ((ImageContext->IsTeImage) && (Hdr.Te->DataDirectory[0].Size == 0) && (Hdr.Te->DataDirectory[0].VirtualAddress == 0)) {
ImageContext->RelocationsStripped = TRUE;
} else {
ImageContext->RelocationsStripped = FALSE;
}