When reapplying PE/COFF relocations for the switch to virtual mode, we
should not assume that the virtual memory image is identical to the
PE/COFF file image, since PE/COFF sections may no longer be adjacent in
virtual memory.

The prototype and implementation of PeCoffLoaderRelocateImageForRuntime
have been updated to account for this, so update the call site as well.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org>
---
 MdeModulePkg/Core/RuntimeDxe/Runtime.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/RuntimeDxe/Runtime.c 
b/MdeModulePkg/Core/RuntimeDxe/Runtime.c
index c61301cf80d8..e660138f1189 100644
--- a/MdeModulePkg/Core/RuntimeDxe/Runtime.c
+++ b/MdeModulePkg/Core/RuntimeDxe/Runtime.c
@@ -212,6 +212,16 @@ RuntimeDriverConvertInternalPointer (
   return RuntimeDriverConvertPointer (0x0, ConvertAddress);
 }
 
+STATIC
+RETURN_STATUS
+EFIAPI
+RuntimeDriverConvertPecoffPointer (
+  IN OUT VOID                       **Address
+  )
+{
+  return (RETURN_STATUS) RuntimeDriverConvertPointer (0x0, Address);
+}
+
 /**
 
   Changes the runtime addressing mode of EFI firmware from physical to virtual.
@@ -314,7 +324,7 @@ RuntimeDriverSetVirtualAddressMap (
 
       PeCoffLoaderRelocateImageForRuntime (
         (EFI_PHYSICAL_ADDRESS) (UINTN) RuntimeImage->ImageBase,
-        VirtImageBase,
+        RuntimeDriverConvertPecoffPointer,
         (UINTN) RuntimeImage->ImageSize,
         RuntimeImage->RelocationData
         );
-- 
1.9.1


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to