From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VzpjGQDk; spf=pass (domain: redhat.com, ip: 207.211.31.120, mailfrom: philmd@redhat.com) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by groups.io with SMTP; Fri, 27 Sep 2019 03:15:33 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1569579332; 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:openpgp:openpgp; bh=gyitG+iKfP66SDiYl+o9W0lBKwYdEs/hfOKhxzUlWzw=; b=VzpjGQDkFOTY+WbLZwDfcbtRU9qfkDKMacFewJ1EzROvRwD1KzX0uZ284xU79hJY1vPVWU TeTZG+ZwkTRMIJP+t/iEDCJ/cxmX412QjXJKr1fHLIKfTPv3juzpazAlMRx/CDmVwkkaxz UhURpe6pX5OeNm3zb75xeja2XHz2L3c= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-217-hjdZ2H5eN-2_s26SWu5eOg-1; Fri, 27 Sep 2019 06:15:24 -0400 Received: by mail-wr1-f72.google.com with SMTP id m14so807658wru.17 for ; Fri, 27 Sep 2019 03:15:24 -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:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=oveZUt2BXLG6tPLb+J9OPKkGTjxLsLL1/OgaOTrnSYc=; b=BvDwuW7a+BZjEU3P8WIazbyJ0gCknUJ81vXvVFBDNc/ABkvsRVfnDvS5ipiHYM2up/ 3hXJ2QfsvHAyXpoxc6X+CSUDojWRi5hV3hwlJWzK0ECPWySgfKyoeKa3tpM9AVBiC+tb 3W3L3rD4NVCPuYMBNHp0g+2mVAPXDUati8woTBk19lVc0JA1ICvPGb1P1xSG2T3nc9p5 cwd7TlL9LGhOEUY2cK8foz9o6uEaj1/zkTCq4LH1HzxjreXWbGAnrowPfiui2yCnM1/s H6q7gu9r0XFuy9FRIRpBDrhXVTOEr9AkvkX2MF07jIhmZ0dTMRhfbPbQvJeabCy+epRY C2vg== X-Gm-Message-State: APjAAAWDkmQRKC4YxGXVtziyhZzRrzhbpEWh1ywol+QOT4nP1G1+J31u uTlbWnA9+i5qEqH6A7pUWkVgmWDPn4O9B/uvKeHb2HVV8otErE4F8aDkMlbt9Vpu1E2wXSOOQvQ rr7g2TolTMeAPSQ== X-Received: by 2002:a5d:5352:: with SMTP id t18mr2457101wrv.72.1569579322897; Fri, 27 Sep 2019 03:15:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5VYZByi5m3Jxh3iXlFVW4eya/sZm5DWg4sMvWwBR9tIRH5jBC1Vd3oRXBLvYytaqdl1Pi8Q== X-Received: by 2002:a5d:5352:: with SMTP id t18mr2457089wrv.72.1569579322732; Fri, 27 Sep 2019 03:15:22 -0700 (PDT) Return-Path: Received: from [192.168.1.35] (240.red-88-21-68.staticip.rima-tde.net. [88.21.68.240]) by smtp.gmail.com with ESMTPSA id b194sm13957504wmg.46.2019.09.27.03.15.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Sep 2019 03:15:22 -0700 (PDT) Subject: Re: [edk2-devel] [Patch 03/12] BaseTools GenFw: Fix the issue to update the wrong size as SectionSize To: devel@edk2.groups.io, liming.gao@intel.com References: <1569570395-11240-1-git-send-email-liming.gao@intel.com> <1569570395-11240-4-git-send-email-liming.gao@intel.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Openpgp: id=89C1E78F601EE86C867495CBA2A3FD6EDEADC0DE; url=http://pgp.mit.edu/pks/lookup?op=get&search=0xA2A3FD6EDEADC0DE Message-ID: <7425adac-290f-91d2-6376-ab52a7d4967f@redhat.com> Date: Fri, 27 Sep 2019 12:15:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <1569570395-11240-4-git-send-email-liming.gao@intel.com> X-MC-Unique: hjdZ2H5eN-2_s26SWu5eOg-1 X-Mimecast-Spam-Score: 0 Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 9/27/19 9:46 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; > + } > + =20 > SectionHeader->PointerToRawData =3D SectionHeader->VirtualAddress; > } > =20 > @@ -999,7 +1003,7 @@ Returns: > CopyMem ( > FileBuffer + SectionHeader->PointerToRawData, > (VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader->Virtua= lAddress), > - SectionHeader->SizeOfRawData > + SectionHeader->SizeOfRawData < SectionHeader->Misc.VirtualSize ? S= ectionHeader->SizeOfRawData : SectionHeader->Misc.VirtualSize > ); > } > =20 >=20 Reviewed-by: Philippe Mathieu-Daude