Per PI1.2B spec, for the case that TE Image Relocation Data Directory Entry Virtual Address is non-zero, but the Relocation Data Directory Size is zero, BasePeCoffLib should only handle such case as PIC TE image.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11315 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4 2011-02-16 01:18:28 +00:00
parent 5788e95470
commit 6beb225a9a
1 changed files with 9 additions and 1 deletions

View File

@ -2,7 +2,7 @@
Base PE/COFF loader supports loading any PE32/PE32+ or TE image, but Base PE/COFF loader supports loading any PE32/PE32+ or TE image, but
only supports relocating IA32, x64, IPF, and EBC images. only supports relocating IA32, x64, IPF, and EBC images.
Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
@ -280,6 +280,14 @@ PeCoffLoaderGetImageInfo (
ImageContext->RelocationsStripped = FALSE; ImageContext->RelocationsStripped = FALSE;
} }
//
// TE Image Relocation Data Directory Entry size is non-zero, but the Relocation Data Directory Virtual Address is zero.
// This case is not a valid TE image.
//
if ((ImageContext->IsTeImage) && (Hdr.Te->DataDirectory[0].Size != 0) && (Hdr.Te->DataDirectory[0].VirtualAddress == 0)) {
return RETURN_INVALID_PARAMETER;
}
if (!(ImageContext->IsTeImage)) { if (!(ImageContext->IsTeImage)) {
if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
// //