]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/GenFw: enhance to use Magic Field to identify the image
authorYonghong Zhu <yonghong.zhu@intel.com>
Thu, 12 May 2016 06:22:56 +0000 (14:22 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Mon, 16 May 2016 01:06:05 +0000 (09:06 +0800)
Original use the File Header Machine Field to identify
EFI_IMAGE_OPTIONAL_HEADER32 or EFI_IMAGE_OPTIONAL_HEADER64, it cannot
correctly handle EBC arch PE32 image.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/C/GenFw/GenFw.c

index 4a91df5d220e261ffbae2d950d36386b2f46715a..03bfaa1c80e860d92b21eb8ac22ac6fbf6ba43da 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Converts a pe32+ image to an FW, Te image type, or other specific image.\r
 \r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -2796,8 +2796,8 @@ Returns:
   // Get Debug, Export and Resource EntryTable RVA address.\r
   // Resource Directory entry need to review.\r
   //\r
-  if (FileHdr->Machine == EFI_IMAGE_MACHINE_IA32) {\r
-    Optional32Hdr = (EFI_IMAGE_OPTIONAL_HEADER32 *) ((UINT8*) FileHdr + sizeof (EFI_IMAGE_FILE_HEADER));\r
+  Optional32Hdr = (EFI_IMAGE_OPTIONAL_HEADER32 *) ((UINT8*) FileHdr + sizeof (EFI_IMAGE_FILE_HEADER));\r
+  if (Optional32Hdr->Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
     SectionHeader = (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) Optional32Hdr +  FileHdr->SizeOfOptionalHeader);\r
     if (Optional32Hdr->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_EXPORT && \\r
         Optional32Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT].Size != 0) {\r