* [patch] MdePkg/BasePeCoffLib: Correct the address of RelocBaseEnd
@ 2019-01-18 8:08 Dandan Bi
2019-01-18 8:59 ` Gary Lin
2019-01-21 0:48 ` Gao, Liming
0 siblings, 2 replies; 3+ messages in thread
From: Dandan Bi @ 2019-01-18 8:08 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael D Kinney, Liming Gao
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>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch] MdePkg/BasePeCoffLib: Correct the address of RelocBaseEnd
2019-01-18 8:08 [patch] MdePkg/BasePeCoffLib: Correct the address of RelocBaseEnd Dandan Bi
@ 2019-01-18 8:59 ` Gary Lin
2019-01-21 0:48 ` Gao, Liming
1 sibling, 0 replies; 3+ messages in thread
From: Gary Lin @ 2019-01-18 8:59 UTC (permalink / raw)
To: Dandan Bi; +Cc: edk2-devel, Michael D Kinney, Liming Gao
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 <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>
Thanks for the patch.
Tested-by: Gary Lin <glin@suse.com>
> ---
> 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] MdePkg/BasePeCoffLib: Correct the address of RelocBaseEnd
2019-01-18 8:08 [patch] MdePkg/BasePeCoffLib: Correct the address of RelocBaseEnd Dandan Bi
2019-01-18 8:59 ` Gary Lin
@ 2019-01-21 0:48 ` Gao, Liming
1 sibling, 0 replies; 3+ messages in thread
From: Gao, Liming @ 2019-01-21 0:48 UTC (permalink / raw)
To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Kinney, Michael D
Reviewed-by: Liming Gao <liming.gao@intel.com>
>-----Original Message-----
>From: Bi, Dandan
>Sent: Friday, January 18, 2019 4:09 PM
>To: edk2-devel@lists.01.org
>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
><liming.gao@intel.com>
>Subject: [patch] 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 <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>
>---
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-21 0:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-18 8:08 [patch] MdePkg/BasePeCoffLib: Correct the address of RelocBaseEnd Dandan Bi
2019-01-18 8:59 ` Gary Lin
2019-01-21 0:48 ` Gao, Liming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox