]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/BasePeCoffLib: Correct the address of RelocBaseEnd
authorDandan Bi <dandan.bi@intel.com>
Thu, 17 Jan 2019 07:25:26 +0000 (15:25 +0800)
committerLiming Gao <liming.gao@intel.com>
Mon, 21 Jan 2019 02:12:04 +0000 (10:12 +0800)
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 <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Tested-by: Gary Lin <glin@suse.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdePkg/Library/BasePeCoffLib/BasePeCoff.c

index d9c94b89bd9da944652ed79047ac22c1ef4dcfcd..1bd079ad6a87f46cc25f37484071ac3c19dd6b71 100644 (file)
@@ -1743,7 +1743,7 @@ PeCoffLoaderRelocateImageForRuntime (
     RelocDir      = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;\r
     RelocBase     = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress (&ImageContext, RelocDir->VirtualAddress, 0);\r
     RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress (&ImageContext,\r
-                                                                            RelocDir->VirtualAddress + RelocDir->Size,\r
+                                                                            RelocDir->VirtualAddress + RelocDir->Size - 1,\r
                                                                             0\r
                                                                             );\r
   } else {\r