From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BFE4F21D0A242 for ; Mon, 14 Aug 2017 00:08:08 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP; 14 Aug 2017 00:10:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,372,1498546800"; d="scan'208";a="299771163" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga004.fm.intel.com with ESMTP; 14 Aug 2017 00:10:32 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 14 Aug 2017 00:10:31 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 14 Aug 2017 00:10:31 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.183]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.128]) with mapi id 14.03.0319.002; Mon, 14 Aug 2017 15:10:29 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" , Andrew Fish Thread-Topic: [Patch] BaseTools: Fix Segmentation fault: 11 when build AppPkg with XCODE5 Thread-Index: AQHTDzG9nrjWB46WkkigpNBVS7AKAqKDemTg Date: Mon, 14 Aug 2017 07:10:29 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D770268@shsmsx102.ccr.corp.intel.com> References: <1502078429-13340-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1502078429-13340-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: Fix Segmentation fault: 11 when build AppPkg with XCODE5 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Aug 2017 07:08:09 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Zhu, Yonghong >Sent: Monday, August 07, 2017 12:00 PM >To: edk2-devel@lists.01.org >Cc: Gao, Liming ; Kinney, Michael D >; Andrew Fish >Subject: [Patch] BaseTools: Fix Segmentation fault: 11 when build AppPkg >with XCODE5 > >it is a bug in mtoc setting the size of the debug directory entry to >the size of the .debug section, not the size of the >EFI_IMAGE_DEBUG_DIRECTORY_ENTRY. It was causing a loop to iterate and >get bogus EFI_IMAGE_DEBUG_DIRECTORY_ENTRY data and pass that to >memset() and boom. > >Cc: Liming Gao >Cc: Michael D Kinney >Contributed-under: TianoCore Contribution Agreement 1.0 >Signed-off-by: Andrew Fish >--- > BaseTools/Source/C/GenFw/GenFw.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > >diff --git a/BaseTools/Source/C/GenFw/GenFw.c >b/BaseTools/Source/C/GenFw/GenFw.c >index 246deb0..af60c92 100644 >--- a/BaseTools/Source/C/GenFw/GenFw.c >+++ b/BaseTools/Source/C/GenFw/GenFw.c >@@ -2813,10 +2813,11 @@ Returns: > // > // Get Debug, Export and Resource EntryTable RVA address. > // Resource Directory entry need to review. > // > Optional32Hdr =3D (EFI_IMAGE_OPTIONAL_HEADER32 *) ((UINT8*) FileHdr + >sizeof (EFI_IMAGE_FILE_HEADER)); >+ Optional64Hdr =3D (EFI_IMAGE_OPTIONAL_HEADER64 *) ((UINT8*) FileHdr + >sizeof (EFI_IMAGE_FILE_HEADER)); > if (Optional32Hdr->Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { > SectionHeader =3D (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) >Optional32Hdr + FileHdr->SizeOfOptionalHeader); > if (Optional32Hdr->NumberOfRvaAndSizes > >EFI_IMAGE_DIRECTORY_ENTRY_EXPORT && \ > Optional32Hdr- >>DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT].Size !=3D 0) { > ExportDirectoryEntryRva =3D Optional32Hdr- >>DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; >@@ -2833,11 +2834,10 @@ Returns: > Optional32Hdr- >>DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size =3D 0; > Optional32Hdr- >>DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress =3D 0; > } > } > } else { >- Optional64Hdr =3D (EFI_IMAGE_OPTIONAL_HEADER64 *) ((UINT8*) FileHdr + >sizeof (EFI_IMAGE_FILE_HEADER)); > SectionHeader =3D (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) >Optional64Hdr + FileHdr->SizeOfOptionalHeader); > if (Optional64Hdr->NumberOfRvaAndSizes > >EFI_IMAGE_DIRECTORY_ENTRY_EXPORT && \ > Optional64Hdr- >>DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT].Size !=3D 0) { > ExportDirectoryEntryRva =3D Optional64Hdr- >>DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; > } >@@ -2907,10 +2907,20 @@ Returns: > RsdsEntry->Unknown =3D 0; > RsdsEntry->Unknown2 =3D 0; > RsdsEntry->Unknown3 =3D 0; > RsdsEntry->Unknown4 =3D 0; > RsdsEntry->Unknown5 =3D 0; >+ } else if (RsdsEntry->Signature =3D=3D CODEVIEW_SIGNATURE_MTOC) { >+ // MTOC sets DebugDirectoryEntrySize to size of the .debug sect= ion, so >fix it. >+ if (!ZeroDebugFlag) { >+ if (Optional32Hdr->Magic =3D=3D >EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { >+ Optional32Hdr- >>DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size =3D sizeof >(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); >+ } else { >+ Optional64Hdr- >>DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size =3D sizeof >(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); >+ } >+ } >+ break; > } > } > } > } > >-- >2.6.1.windows.1