From nobody Mon Feb 9 00:02:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+49160+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49160+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1571295370; cv=none; d=zoho.com; s=zohoarc; b=Kk3K3ZtQPkvlc6BiCkPK405INEwv5tjZdc3pZIOkAmYN1w3Ci30+G4y9cJC+/9hMBheEWZtXEAYA1MVs5Tg8/tQIgR+7/KxODnC1EsFxRHEU4P/69JDoboJhtgNSxqT759Oqlc4t+vccdi8p2Zud+57gw/hSjM3P5Rjn57ZIG64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571295370; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=wD5noJgCI9kgZbRK7sjxKPgR2P95QSlJSRkcCpEzeYo=; b=nILEhlYRHjSiKLlTG5ez7hoyMTRwhvPp1TVRfIikcUpxrHnKrXXFvzG2FGxfwXmJc9CnJr+OJYtj0HQeijdMUdeqEIp4FKsYguB1J4PZgjp8fefSDjCN6zUHTC+iwvEyRm7ciW3Kd3PX2+/lDe2wwNv59ZcjJOQrSt29iBijic0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49160+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1571295370446121.7179016587038; Wed, 16 Oct 2019 23:56:10 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id MSFNYY1788612xJkJAWeJPkX; Wed, 16 Oct 2019 23:56:10 -0700 X-Received: from mga09.intel.com (mga09.intel.com []) by mx.groups.io with SMTP id smtpd.web10.3108.1571295367890091277 for ; Wed, 16 Oct 2019 23:56:09 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2019 23:56:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,306,1566889200"; d="scan'208";a="208577858" X-Received: from shwde7172.ccr.corp.intel.com ([10.239.158.22]) by fmsmga001.fm.intel.com with ESMTP; 16 Oct 2019 23:56:08 -0700 From: "Liming Gao" To: devel@edk2.groups.io Cc: Bob Feng Subject: [edk2-devel] [Patch v3 03/11] BaseTools GenFw: Fix the issue to update the wrong size as SectionSize Date: Thu, 17 Oct 2019 14:55:47 +0800 Message-Id: <1571295356-11608-4-git-send-email-liming.gao@intel.com> In-Reply-To: <1571295356-11608-1-git-send-email-liming.gao@intel.com> References: <1571295356-11608-1-git-send-email-liming.gao@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liming.gao@intel.com X-Gm-Message-State: M7Y66VlB0v0Kk4jgX22rY6Wwx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1571295370; bh=+Qmxn8FHR9decd3jL0tDkeK0QGAN2ctgtK961YdksTQ=; h=Cc:Date:From:Reply-To:Subject:To; b=LSaN9sJE71iTR0xAb8N14V70YEtyCwhBQvg+zaC2+zM9uLi27JldTyLKulTG5BlU2Qw PiiF4Y0pxAXqniIyxtkJEZT2yiAAbef6Sdl+qOkdgH+L+zEAOIU+chUo7Qpad46FPMNYP zfgCEcL5ZTg+ThS1KVyRFFDwTWE2rOl4kLE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1603 CLANG9 generated PE image exposes below two issues. 1. SectionSize is used to copy PE section data. It should be smaller than section raw size. 2. The real data is required to be copied. So, copy the min size of VirtualSize and SizeOfRawData. Signed-off-by: Liming Gao Cc: Bob Feng Reviewed-by: Philippe Mathieu-Daude Reviewed-by: Bob Feng --- 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/Ge= nFw.c index c99782b78e..8cab70ba4d 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 + Pe= Hdr->Pe32.OptionalHeader.FileAlignment - 1) & (~(PeHdr->Pe32.OptionalHeader= .FileAlignment - 1)); + SectionSize =3D (SectionHeader->Misc.VirtualSize + PeHdr->Pe32.Optiona= lHeader.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->VirtualA= ddress), - SectionHeader->SizeOfRawData + SectionHeader->SizeOfRawData < SectionHeader->Misc.VirtualSize ? Sec= tionHeader->SizeOfRawData : SectionHeader->Misc.VirtualSize ); } =20 --=20 2.13.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#49160): https://edk2.groups.io/g/devel/message/49160 Mute This Topic: https://groups.io/mt/34694437/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-