From eb76b76218d5bac867414e2ff6dd09c6e7c700dd Mon Sep 17 00:00:00 2001 From: Dandan Bi Date: Thu, 17 Jan 2019 15:25:26 +0800 Subject: MdePkg/BasePeCoffLib: Correct the address of RelocBaseEnd 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 Tested-by: Gary Lin Reviewed-by: Liming Gao --- MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MdePkg/Library') 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 @@ -1743,7 +1743,7 @@ PeCoffLoaderRelocateImageForRuntime ( 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 { -- cgit v1.2.3