Fix PeiLoadImage() for compressed peim to print the correct image address and entrypoint.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 5 Sep 2006 11:28:57 +0000 (11:28 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 5 Sep 2006 11:28:57 +0000 (11:28 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1467 6f19259b-4bc3-4df7-8a09-765794883524

EdkModulePkg/Core/Pei/Image/Image.c

index c5c68c1..6a26bb2 100644 (file)
@@ -105,10 +105,10 @@ Returns:
       }\r
 \r
       //\r
-      // Got the entry point from ImageEntryPoint\r
+      // Got the entry point from ImageEntryPoint and ImageStartAddress\r
       //\r
+      Pe32Data    = (VOID *) ((UINTN) ImageAddress);\r
       *EntryPoint = (VOID *) ((UINTN) ImageEntryPoint);\r
-      return EFI_SUCCESS;\r
     } else {\r
       //\r
       // Retrieve the entry point from the TE image header\r
@@ -171,23 +171,27 @@ Returns:
     // is present in the image. You have to check the NumberOfRvaAndSizes in\r
     // the optional header to verify a desired directory entry is there.\r
     //\r
-    DebugEntry      = NULL;\r
-    DirectoryEntry  = NULL;\r
-    TEImageAdjust   = 0;\r
+    DebugEntry          = NULL;\r
+    DirectoryEntry      = NULL;\r
+    NumberOfRvaAndSizes = 0;\r
+    TEImageAdjust       = 0;\r
+    \r
     if (TEImageHeader == NULL) {\r
       if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
         //     \r
-        // Use PE32 offset\r
+        // Use PE32 offset get Debug Directory Entry\r
         //\r
         NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;\r
         DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
-      } else {\r
+        DebugEntry     = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);\r
+      } else if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
         //     \r
-        // Use PE32+ offset\r
+        // Use PE32+ offset get Debug Directory Entry\r
         //\r
         NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;\r
         DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
-      }    \r
+        DebugEntry     = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);\r
+      }\r
 \r
       if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
         DirectoryEntry = NULL;\r