From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.3151.1571218040974601353 for ; Wed, 16 Oct 2019 02:27:21 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: bob.c.feng@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2019 02:27:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,303,1566889200"; d="scan'208";a="347371292" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 16 Oct 2019 02:27:20 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 16 Oct 2019 02:27:20 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 16 Oct 2019 02:27:19 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.166]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.165]) with mapi id 14.03.0439.000; Wed, 16 Oct 2019 17:27:18 +0800 From: "Bob Feng" 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 Thread-Topic: [edk2-devel] [Patch v2 03/11] BaseTools GenFw: Fix the issue to update the wrong size as SectionSize Thread-Index: AQHVgu9VooDXKBcB3kOSqDpt9WHSHadc//UQ Date: Wed, 16 Oct 2019 09:27:17 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D16154B171@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> In-Reply-To: <1571099210-12432-4-git-send-email-liming.gao@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: bob.c.feng@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 re= lationship between CLANG9 and this fix and why the original code is wrong. Thanks Bob -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Limi= ng 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 u= pdate 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/G= enFw.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 + P= eHdr->Pe32.OptionalHeader.FileAlignment - 1) & (~(PeHdr->Pe32.OptionalHeade= r.FileAlignment - 1)); + SectionSize =3D (SectionHeader->Misc.VirtualSize + PeHdr->Pe32.Option= alHeader.FileAlignment - 1) & (~(PeHdr->Pe32.OptionalHeader.FileAlignment -= 1)); + if (SectionSize < SectionHeader->SizeOfRawData) { + SectionHeader->SizeOfRawData =3D SectionSize; + } + SectionHeader->PointerToRawData =3D SectionHeader->VirtualAddress; } =20 @@ -999,7 +1003,7 @@ Returns: CopyMem ( FileBuffer + SectionHeader->PointerToRawData, (VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader->Virtual= Address), - SectionHeader->SizeOfRawData + SectionHeader->SizeOfRawData < SectionHeader->Misc.VirtualSize ? Se= ctionHeader->SizeOfRawData : SectionHeader->Misc.VirtualSize ); } =20 --=20 2.13.0.windows.1