From nobody Fri Dec 27 17:54:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1499059296503816.8784063453007; Sun, 2 Jul 2017 22:21:36 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B39B821CAD9BD; Sun, 2 Jul 2017 22:19:57 -0700 (PDT) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 5740C21CAD9A7 for ; Sun, 2 Jul 2017 22:19:56 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jul 2017 22:21:27 -0700 Received: from shwde7172.ccr.corp.intel.com ([10.239.9.14]) by fmsmga002.fm.intel.com with ESMTP; 02 Jul 2017 22:21:27 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,301,1496127600"; d="scan'208";a="1189855432" From: Liming Gao To: edk2-devel@lists.01.org Date: Mon, 3 Jul 2017 13:21:21 +0800 Message-Id: <1499059281-11744-1-git-send-email-liming.gao@intel.com> X-Mailer: git-send-email 2.8.0.windows.1 Subject: [edk2] [Patch] BaseTools: Update GenFw to clear unused debug entry generated by VS tool chain 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D600 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao Reviewed-by: Yonghong Zhu =20 --- BaseTools/Source/C/GenFw/GenFw.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/Ge= nFw.c index 22e4e72..6569460 100644 --- a/BaseTools/Source/C/GenFw/GenFw.c +++ b/BaseTools/Source/C/GenFw/GenFw.c @@ -2770,6 +2770,7 @@ Returns: { UINT32 Index; UINT32 DebugDirectoryEntryRva; + UINT32 DebugDirectoryEntrySize; UINT32 DebugDirectoryEntryFileOffset; UINT32 ExportDirectoryEntryRva; UINT32 ExportDirectoryEntryFileOffset; @@ -2781,12 +2782,14 @@ Returns: EFI_IMAGE_OPTIONAL_HEADER64 *Optional64Hdr; EFI_IMAGE_SECTION_HEADER *SectionHeader; EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry; + EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY *RsdsEntry; UINT32 *NewTimeStamp; =20 =20 // // Init variable. // DebugDirectoryEntryRva =3D 0; + DebugDirectoryEntrySize =3D 0; ExportDirectoryEntryRva =3D 0; ResourceDirectoryEntryRva =3D 0; DebugDirectoryEntryFileOffset =3D 0; @@ -2822,6 +2825,7 @@ Returns: if (Optional32Hdr->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEB= UG && \ Optional32Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size= !=3D 0) { DebugDirectoryEntryRva =3D Optional32Hdr->DataDirectory[EFI_IMAGE_DI= RECTORY_ENTRY_DEBUG].VirtualAddress; + DebugDirectoryEntrySize =3D Optional32Hdr->DataDirectory[EFI_IMAGE_D= IRECTORY_ENTRY_DEBUG].Size; if (ZeroDebugFlag) { Optional32Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size= =3D 0; Optional32Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Virt= ualAddress =3D 0; @@ -2841,6 +2845,7 @@ Returns: if (Optional64Hdr->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEB= UG && \ Optional64Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size= !=3D 0) { DebugDirectoryEntryRva =3D Optional64Hdr->DataDirectory[EFI_IMAGE_DI= RECTORY_ENTRY_DEBUG].VirtualAddress; + DebugDirectoryEntrySize =3D Optional64Hdr->DataDirectory[EFI_IMAGE_D= IRECTORY_ENTRY_DEBUG].Size; if (ZeroDebugFlag) { Optional64Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size= =3D 0; Optional64Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Virt= ualAddress =3D 0; @@ -2886,11 +2891,23 @@ Returns: =20 if (DebugDirectoryEntryFileOffset !=3D 0) { DebugEntry =3D (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) (FileBuffer + Debug= DirectoryEntryFileOffset); - DebugEntry->TimeDateStamp =3D 0; - mImageTimeStamp =3D 0; - if (ZeroDebugFlag) { - memset (FileBuffer + DebugEntry->FileOffset, 0, DebugEntry->SizeOfDa= ta); - memset (DebugEntry, 0, sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)); + Index =3D 0; + for (Index=3D0; Index < DebugDirectoryEntrySize / sizeof (EFI_IMAGE_DE= BUG_DIRECTORY_ENTRY); Index ++, DebugEntry ++) { + DebugEntry->TimeDateStamp =3D 0; + if (ZeroDebugFlag || DebugEntry->Type !=3D EFI_IMAGE_DEBUG_TYPE_CODE= VIEW) { + memset (FileBuffer + DebugEntry->FileOffset, 0, DebugEntry->SizeOf= Data); + memset (DebugEntry, 0, sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)); + } + if (DebugEntry->Type =3D=3D EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { + RsdsEntry =3D (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY *) (FileBuffer = + DebugEntry->FileOffset); + if (RsdsEntry->Signature =3D=3D CODEVIEW_SIGNATURE_RSDS) { + RsdsEntry->Unknown =3D 0; + RsdsEntry->Unknown2 =3D 0; + RsdsEntry->Unknown3 =3D 0; + RsdsEntry->Unknown4 =3D 0; + RsdsEntry->Unknown5 =3D 0; + } + } } } =20 --=20 2.8.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel