Especially in the relative mode, fixed-address loading may not target
the preferred Image base address. In this case, Image relocations are
required to load the Image. Add the necessary check for this.

Cc: Jian J Wang <jian.j.w...@intel.com>
Cc: Hao A Wu <hao.a...@intel.com>
Cc: Dandan Bi <dandan...@intel.com>
Cc: Liming Gao <gaolim...@byosoft.com.cn>
Cc: Vitaly Cheptsov <vit9...@protonmail.com>
Signed-off-by: Marvin Häuser <mhaeu...@posteo.de>
---
 MdeModulePkg/Core/Dxe/Image/Image.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c 
b/MdeModulePkg/Core/Dxe/Image/Image.c
index 0a1def0572bc..a19be4c2a4a9 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.c
+++ b/MdeModulePkg/Core/Dxe/Image/Image.c
@@ -647,7 +647,13 @@ CoreLoadPeImage (
 

       Status = GetPeCoffImageFixLoadingAssignedAddress 
(&(Image->ImageContext));

 

-      if (EFI_ERROR (Status))  {

+      if (!EFI_ERROR (Status))  {

+          if (PreferredAddress != Image->ImageContext.ImageAddress && 
Image->ImageContext.RelocationsStripped) {

+            Status = EFI_UNSUPPORTED;

+            DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED ERROR: 
Loading module at fixed address failed since relocations have been 
stripped.\n"));

+            Image->ImageContext.ImageAddress = PreferredAddress;

+          }

+      } else {

           //

           // If the code memory is not ready, invoke CoreAllocatePage with 
AllocateAnyPages to load the driver.

           //

-- 
2.31.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79673): https://edk2.groups.io/g/devel/message/79673
Mute This Topic: https://groups.io/mt/85048611/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to