diff options
author | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-04-09 01:42:09 +0000 |
---|---|---|
committer | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-04-09 01:42:09 +0000 |
commit | 28dec501f4d43e24f9dc9f121d8166fcb7f8ff35 (patch) | |
tree | 9392a555ef0f0f175ecefd448ea9265708378980 /MdePkg | |
parent | abb234751e4fbe58afc5e7c7e203db2a93aac0f8 (diff) | |
download | edk2-platforms-28dec501f4d43e24f9dc9f121d8166fcb7f8ff35.tar.xz |
Fix an issue that some image tool will generate PE32+ image with PE32 magic. We now determine magic based on machine type.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2547 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg')
-rw-r--r-- | MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c b/MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c index d0a6746e50..ab60297776 100644 --- a/MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c +++ b/MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c @@ -136,6 +136,7 @@ PeCoffLoaderGetPdbPointer ( VOID *CodeViewEntryPointer;
INTN TEImageAdjust;
UINT32 NumberOfRvaAndSizes;
+ UINT16 Magic;
ASSERT (Pe32Data != NULL);
@@ -166,7 +167,33 @@ PeCoffLoaderGetPdbPointer ( TEImageAdjust);
}
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
- if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // NOTE: We use Machine field to identify PE32/PE32+, instead of Magic.
+ // It is due to backward-compatibility, for some system might
+ // generate PE32+ image with PE32 Magic.
+ //
+ switch (Hdr.Pe32->FileHeader.Machine) {
+ case EFI_IMAGE_MACHINE_IA32:
+ //
+ // Assume PE32 image with IA32 Machine field.
+ //
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+ break;
+ case EFI_IMAGE_MACHINE_X64:
+ case EFI_IMAGE_MACHINE_IPF:
+ //
+ // Assume PE32+ image with X64 or IPF Machine field
+ //
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ break;
+ default:
+ //
+ // For unknow Machine field, use Magic in optional Header
+ //
+ Magic = Hdr.Pe32->OptionalHeader.Magic;
+ }
+
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
//
// Use PE32 offset get Debug Directory Entry
//
|