Fix incorrect image base for TE image

TE image has stripped header to reduce the image size. When calculating
the preferred base for TE image, the gap should be added back in order
to match the actual TE image base. This patch fixed #133.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
This commit is contained in:
Maurice Ma
2019-04-12 09:40:01 -07:00
parent ef4dbd9177
commit 3dfcd913eb
@@ -292,7 +292,7 @@ PeCoffGetPreferredBase (
// Common for PE32 & PE32+
//
if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
ImageBase = (UINT32)Hdr.Te->ImageBase;
ImageBase = (UINT32)Hdr.Te->ImageBase + Hdr.Te->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER);
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
ImageBase = Hdr.Pe32->OptionalHeader.ImageBase;
} else {