From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.1473.1571278733539091421 for ; Wed, 16 Oct 2019 19:18:53 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: liming.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2019 19:18:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,306,1566889200"; d="scan'208";a="200245971" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga006.jf.intel.com with ESMTP; 16 Oct 2019 19:18:52 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 16 Oct 2019 19:18:52 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 16 Oct 2019 19:18:52 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 16 Oct 2019 19:18:51 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.166]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.96]) with mapi id 14.03.0439.000; Thu, 17 Oct 2019 10:18:50 +0800 From: "Liming Gao" To: "Feng, Bob C" , "devel@edk2.groups.io" Subject: Re: [edk2-devel] [Patch v2 03/11] BaseTools GenFw: Fix the issue to update the wrong size as SectionSize Thread-Topic: [edk2-devel] [Patch v2 03/11] BaseTools GenFw: Fix the issue to update the wrong size as SectionSize Thread-Index: AQHVgu9Vt3Dq39QODEi6zaiU8zRPSKdc//UQgAEbsqA= Date: Thu, 17 Oct 2019 02:18:49 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E51D630@SHSMSX104.ccr.corp.intel.com> References: <1571099210-12432-1-git-send-email-liming.gao@intel.com> <1571099210-12432-4-git-send-email-liming.gao@intel.com> <08650203BA1BD64D8AD9B6D5D74A85D16154B171@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <08650203BA1BD64D8AD9B6D5D74A85D16154B171@SHSMSX104.ccr.corp.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 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable OK. I will update the commit message to describe this issue.=20 This change is to make sure section size is in section raw data scope.=20 >-----Original Message----- >From: Feng, Bob C >Sent: Wednesday, October 16, 2019 5:27 PM >To: devel@edk2.groups.io; Gao, Liming >Subject: RE: [edk2-devel] [Patch v2 03/11] BaseTools GenFw: Fix the issue= to >update the wrong size as SectionSize > >Hi Liming, > >Would you please add more description in commit message? This patch is in >the patch set of CLANG9 enabling, but it's hard for me to see the direct >relationship between CLANG9 and this fix and why the original code is wro= ng. > >Thanks >Bob > >-----Original Message----- >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of >Liming Gao >Sent: Tuesday, October 15, 2019 8:27 AM >To: devel@edk2.groups.io >Subject: [edk2-devel] [Patch v2 03/11] BaseTools GenFw: Fix the issue to >update the wrong size as SectionSize > >Signed-off-by: Liming Gao >--- > BaseTools/Source/C/GenFw/GenFw.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > >diff --git a/BaseTools/Source/C/GenFw/GenFw.c >b/BaseTools/Source/C/GenFw/GenFw.c >index c99782b78e..d8d3360c24 100644 >--- a/BaseTools/Source/C/GenFw/GenFw.c >+++ b/BaseTools/Source/C/GenFw/GenFw.c >@@ -653,7 +653,11 @@ PeCoffConvertImageToXip ( > // > // Make the size of raw data in section header alignment. > // >- SectionHeader->SizeOfRawData =3D (SectionHeader->Misc.VirtualSize + >PeHdr->Pe32.OptionalHeader.FileAlignment - 1) & (~(PeHdr- >>Pe32.OptionalHeader.FileAlignment - 1)); >+ SectionSize =3D (SectionHeader->Misc.VirtualSize + PeHdr- >>Pe32.OptionalHeader.FileAlignment - 1) & (~(PeHdr- >>Pe32.OptionalHeader.FileAlignment - 1)); >+ if (SectionSize < SectionHeader->SizeOfRawData) { >+ SectionHeader->SizeOfRawData =3D SectionSize; >+ } >+ > SectionHeader->PointerToRawData =3D SectionHeader->VirtualAddress; > } > >@@ -999,7 +1003,7 @@ Returns: > CopyMem ( > FileBuffer + SectionHeader->PointerToRawData, > (VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader- >>VirtualAddress), >- SectionHeader->SizeOfRawData >+ SectionHeader->SizeOfRawData < SectionHeader->Misc.VirtualSize ? >SectionHeader->SizeOfRawData : SectionHeader->Misc.VirtualSize > ); > } > >-- >2.13.0.windows.1 > > >