From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=195.135.221.5; helo=smtp.nue.novell.com; envelope-from=glin@suse.com; receiver=edk2-devel@lists.01.org Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BE95621B02822 for ; Fri, 18 Jan 2019 00:59:58 -0800 (PST) Received: from emea4-mta.ukb.novell.com ([10.120.13.87]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Fri, 18 Jan 2019 09:59:56 +0100 Received: from GaryWorkstation (nwb-a10-snat.microfocus.com [10.120.13.202]) by emea4-mta.ukb.novell.com with ESMTP (TLS encrypted); Fri, 18 Jan 2019 08:59:40 +0000 Date: Fri, 18 Jan 2019 16:59:35 +0800 From: Gary Lin To: Dandan Bi Cc: edk2-devel@lists.01.org, Michael D Kinney , Liming Gao Message-ID: <20190118085935.GS3972@GaryWorkstation> References: <20190118080857.5016-1-dandan.bi@intel.com> MIME-Version: 1.0 In-Reply-To: <20190118080857.5016-1-dandan.bi@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [patch] MdePkg/BasePeCoffLib: Correct the address of RelocBaseEnd X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2019 08:59:59 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Jan 18, 2019 at 04:08:57PM +0800, Dandan Bi wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1426 > > When calculating the address of RelocBaseEnd, > the RelocBase address is ImageBase + RelocDir->VirtualAddress, > the size of RelocDir is RelocDir->Size. > So the RelocBaseEnd address is: > ImageBase + RelocDir->VirtualAddress + RelocDir->Size - 1 > not > ImageBase + RelocDir->VirtualAddress + RelocDir->Size > > This patch is to fix this issue when call PeCoffLoaderImageAddress > function to calculate the address of RelocBaseEnd. > > Cc: Michael D Kinney > Cc: Liming Gao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Dandan Bi Thanks for the patch. Tested-by: Gary Lin > --- > MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > index d9c94b89bd..1bd079ad6a 100644 > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > @@ -1741,11 +1741,11 @@ PeCoffLoaderRelocateImageForRuntime ( > // > if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) { > RelocDir = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC; > RelocBase = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress (&ImageContext, RelocDir->VirtualAddress, 0); > RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress (&ImageContext, > - RelocDir->VirtualAddress + RelocDir->Size, > + RelocDir->VirtualAddress + RelocDir->Size - 1, > 0 > ); > } else { > // > // Cannot find relocations, cannot continue to relocate the image, ASSERT for this invalid image. > -- > 2.18.0.windows.1 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel >