From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 D0FAA211B5A2D for ; Sun, 20 Jan 2019 16:48:03 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jan 2019 16:48:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,501,1539673200"; d="scan'208";a="118151385" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga008.fm.intel.com with ESMTP; 20 Jan 2019 16:48:02 -0800 Received: from fmsmsx125.amr.corp.intel.com (10.18.125.40) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 20 Jan 2019 16:48:02 -0800 Received: from shsmsx153.ccr.corp.intel.com (10.239.6.53) by FMSMSX125.amr.corp.intel.com (10.18.125.40) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 20 Jan 2019 16:48:02 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.159]) by SHSMSX153.ccr.corp.intel.com ([169.254.12.188]) with mapi id 14.03.0415.000; Mon, 21 Jan 2019 08:48:00 +0800 From: "Gao, Liming" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" Thread-Topic: [patch] MdePkg/BasePeCoffLib: Correct the address of RelocBaseEnd Thread-Index: AQHUrwUg93W2IuHgN0i1SqCJ5QNR96W459gA Date: Mon, 21 Jan 2019 00:48:00 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3BCD3C@SHSMSX104.ccr.corp.intel.com> References: <20190118080857.5016-1-dandan.bi@intel.com> In-Reply-To: <20190118080857.5016-1-dandan.bi@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 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: Mon, 21 Jan 2019 00:48:04 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Bi, Dandan >Sent: Friday, January 18, 2019 4:09 PM >To: edk2-devel@lists.01.org >Cc: Kinney, Michael D ; Gao, Liming > >Subject: [patch] MdePkg/BasePeCoffLib: Correct the address of RelocBaseEnd > >REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1426 > >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 >--- > 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 =3D DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC= ; > RelocBase =3D (EFI_IMAGE_BASE_RELOCATION *) >PeCoffLoaderImageAddress (&ImageContext, RelocDir->VirtualAddress, 0); > RelocBaseEnd =3D (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, AS= SERT >for this invalid image. >-- >2.18.0.windows.1