summaryrefslogtreecommitdiffstats
path: root/BaseTools
diff options
context:
space:
mode:
authorYonghong Zhu <yonghong.zhu@intel.com>2016-05-12 14:22:56 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2016-05-16 09:06:05 +0800
commit849e54aa6400b220fad8af32d3d329117e0ceac8 (patch)
tree7a79b27f921c62c848d2197061899600f8c3d757 /BaseTools
parent4ce415e55d93a9ae9fa1fbd6b40080877ae5f23b (diff)
downloadedk2-849e54aa6400b220fad8af32d3d329117e0ceac8.tar.gz
edk2-849e54aa6400b220fad8af32d3d329117e0ceac8.tar.bz2
edk2-849e54aa6400b220fad8af32d3d329117e0ceac8.zip
BaseTools/GenFw: enhance to use Magic Field to identify the image
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>
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/C/GenFw/GenFw.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index 4a91df5d22..03bfaa1c80 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -1,7 +1,7 @@
/** @file
Converts a pe32+ image to an FW, Te image type, or other specific image.
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -2796,8 +2796,8 @@ Returns:
// Get Debug, Export and Resource EntryTable RVA address.
// Resource Directory entry need to review.
//
- if (FileHdr->Machine == EFI_IMAGE_MACHINE_IA32) {
- Optional32Hdr = (EFI_IMAGE_OPTIONAL_HEADER32 *) ((UINT8*) FileHdr + sizeof (EFI_IMAGE_FILE_HEADER));
+ Optional32Hdr = (EFI_IMAGE_OPTIONAL_HEADER32 *) ((UINT8*) FileHdr + sizeof (EFI_IMAGE_FILE_HEADER));
+ if (Optional32Hdr->Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
SectionHeader = (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) Optional32Hdr + FileHdr->SizeOfOptionalHeader);
if (Optional32Hdr->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_EXPORT && \
Optional32Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT].Size != 0) {