From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web12.1485.1571131302436156623 for ; Tue, 15 Oct 2019 02:21:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ehSVP4x6; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571131301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u0Aw336k/sVSX/VBT8ltt4xAzy+knGksHnXu79hQ4Bo=; b=ehSVP4x6A6cB/mR1ySc/zrJZ6gQtkbyh/48p8ArgDp6Obnd9E9CaPKRIju9xIduZ+yft/v dFhYcm7Nfsjr6k8U3uvNSk/Szt4hCiZEqxl+ffiC8GCVuyCZ7t4gcYqY+CibwzCZZZKwFJ 5FKLWZwaADEbBQMYcOh2k1P4tKU5Zf4= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-18-l1sFAIbhP1CMX7n42oWbmQ-1; Tue, 15 Oct 2019 05:21:39 -0400 Received: by mail-wr1-f71.google.com with SMTP id t11so9816554wro.10 for ; Tue, 15 Oct 2019 02:21:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ywo2mIUH6H/petqRdSqyVXybWbMHq77hzFSl7SAKU1I=; b=KcfSSacOWBIY1vwafIhqyey0WQReE/7lDpyZQ3w5CwkNuuR7FlOnDI32Pr4u8FYb2y hdsTTTeFD22fVBrpGgLQkhsuONwRf/+r3Pjf4g1fZOSrjEYto7580ugLAhhtBbP4VSaN 3ltW34FZQB0xzR5pDQNH9hEQxA522daeyJOC6u/HPlkyILZv95sWkrOelBTPdNyhu856 /Z4BJXQ61NAbqASNXKRlxs/417mUCuE5TW0Kp4NDl1h7uGNTuqWSg1PZCqX0Id+17zww n9aqEFlGm+EET5neX6gh5NuSEjV/Hps1UmAXkZDuKy5LAqvhqKF8BthUg9OFo8yQPhxo S1rQ== X-Gm-Message-State: APjAAAXFpeLz6D5iaTawWm++GZi+LWr4dVvoFmBJdSv2FKwjzzcXj9BC iC/WYNbZty44fro/BkzUJYVMzz/ITSgF4Ta0NFlYsp6nXSSa9jUwRQCILvNQ1rL0m1vJT4FvIlU F07aZD4Gw88vTNQ== X-Received: by 2002:a5d:4b09:: with SMTP id v9mr28404888wrq.127.1571131298033; Tue, 15 Oct 2019 02:21:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzG1qTs4OyE+/OI2dVz6bOGazaIroLKC3TkzQsy6cD/C6iykPVBDsE+gIPbTghIClhV4XvaSQ== X-Received: by 2002:a5d:4b09:: with SMTP id v9mr28404874wrq.127.1571131297795; Tue, 15 Oct 2019 02:21:37 -0700 (PDT) Return-Path: Received: from [192.168.1.36] (14.red-88-21-201.staticip.rima-tde.net. [88.21.201.14]) by smtp.gmail.com with ESMTPSA id f83sm32345162wmf.43.2019.10.15.02.21.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Oct 2019 02:21:37 -0700 (PDT) Subject: Re: [edk2-devel] [Patch v2 03/11] BaseTools GenFw: Fix the issue to update the wrong size as SectionSize To: devel@edk2.groups.io, liming.gao@intel.com References: <1571099210-12432-1-git-send-email-liming.gao@intel.com> <1571099210-12432-4-git-send-email-liming.gao@intel.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Message-ID: Date: Tue, 15 Oct 2019 11:21:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <1571099210-12432-4-git-send-email-liming.gao@intel.com> X-MC-Unique: l1sFAIbhP1CMX7n42oWbmQ-1 X-Mimecast-Spam-Score: 0 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable On 10/15/19 2:26 AM, Liming Gao wrote: > Signed-off-by: Liming Gao > --- > BaseTools/Source/C/GenFw/GenFw.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > 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.OptionalHead= er.FileAlignment - 1)); > + SectionSize =3D (SectionHeader->Misc.VirtualSize + PeHdr->Pe32.Optio= nalHeader.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->Virtu= alAddress), > - SectionHeader->SizeOfRawData > + SectionHeader->SizeOfRawData < SectionHeader->Misc.VirtualSize ? S= ectionHeader->SizeOfRawData : SectionHeader->Misc.VirtualSize > ); > } > =20 >=20 Reviewed-by: Philippe Mathieu-Daude