Fixed bugs found when this code was ported into R8.
authorajfish <ajfish@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 11 Aug 2006 18:04:56 +0000 (18:04 +0000)
committerajfish <ajfish@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 11 Aug 2006 18:04:56 +0000 (18:04 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1240 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/BasePeCoffLib/BasePeCoff.c

index ebc3b3cc6c558a5b7dac7affe61279415db890f4..eee4dc713fe746684f080a2ae07eab64be272f9f 100644 (file)
@@ -610,7 +610,7 @@ PeCoffLoaderRelocateImage (
     }\r
   } else {\r
     Hdr.Te             = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);\r
-    Adjust            = (UINT64) (BaseAddress - Hdr.Te->ImageBase);\r
+    Adjust             = (UINT64) (BaseAddress - Hdr.Te->ImageBase);\r
     Hdr.Te->ImageBase  = (UINT64) (BaseAddress);\r
 \r
     //\r
@@ -1200,13 +1200,13 @@ PeCoffLoaderRelocateImageForRuntime (
     // Use PE32 offset\r
     //\r
     NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;\r
-    DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+    DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[0]);\r
   } else {\r
     //     \r
     // Use PE32+ offset\r
     //\r
     NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;\r
-    DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+    DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[0]);\r
   }    \r
 \r
   //\r
@@ -1258,7 +1258,7 @@ PeCoffLoaderRelocateImageForRuntime (
       case EFI_IMAGE_REL_BASED_HIGH:\r
         F16 = (UINT16 *) Fixup;\r
         if (*(UINT16 *) FixupData == *F16) {\r
-          *F16 = (UINT16) ((*F16 << 16) + ((UINT16) Adjust & 0xffff));\r
+          *F16 = (UINT16) (*F16 + ((UINT16)(Adjust >> 16)));\r
         }\r
 \r
         FixupData = FixupData + sizeof (UINT16);\r
@@ -1286,9 +1286,11 @@ PeCoffLoaderRelocateImageForRuntime (
       case EFI_IMAGE_REL_BASED_DIR64:\r
         F64       = (UINT64 *)Fixup;\r
         FixupData = ALIGN_POINTER (FixupData, sizeof (UINT64));\r
-        if (*(UINT32 *) FixupData == *F64) {\r
+        if (*(UINT64 *) FixupData == *F64) {\r
           *F64 = *F64 + (UINT64)Adjust;\r
         }\r
+\r
+        FixupData = FixupData + sizeof (UINT64);\r
         break;\r
 \r
       case EFI_IMAGE_REL_BASED_HIGHADJ:\r