]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Handle new relocation type EFI_IMAGE_REL_BASED_DIR64 for X64.
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 8 Dec 2006 03:43:57 +0000 (03:43 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 8 Dec 2006 03:43:57 +0000 (03:43 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2075 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/BasePeCoffLib/x64/PeCoffLoaderEx.c
Tools/CCode/Source/PeCoffLoader/X64/PeCoffLoaderEx.c

index 7141adc2ad5ddc5d06ad50f1ca38864022c1f47f..8628dc7df12a1ce9ac858fb25d99e54ac819357f 100644 (file)
@@ -1,16 +1,14 @@
 /** @file\r
   x64 Specific relocation fixups.\r
 \r
-  Copyright (c) 2006, Intel Corporation\r
-  All rights reserved. This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-  Module Name:  PeCoffLoaderEx.c\r
+Copyright (c) 2005 - 2006 Intel Corporation. <BR>\r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
 **/\r
 \r
   @param  FixupData   Pointer to a buffer to log the fixups\r
   @param  Adjust      The offset to adjust the fixup\r
 \r
+  @retval RETURN_SUCCESS      Success to perform relocation\r
+  @retval RETURN_UNSUPPORTED  Unsupported.\r
 **/\r
 RETURN_STATUS\r
 PeCoffLoaderRelocateImageEx (\r
-  IN UINT16      *Reloc,\r
-  IN OUT CHAR8   *Fixup, \r
-  IN OUT CHAR8   **FixupData,\r
-  IN UINT64      Adjust\r
+  IN     UINT16       *Reloc,\r
+  IN OUT CHAR8        *Fixup, \r
+  IN OUT CHAR8        **FixupData,\r
+  IN     UINT64       Adjust\r
   )\r
 {\r
   return RETURN_UNSUPPORTED;\r
@@ -64,7 +64,7 @@ PeCoffLoaderImageFormatSupported (
 \r
 \r
 /**\r
-  Performs an Itanium-based specific re-relocation fixup and is a no-op on other\r
+  Performs an X64 specific re-relocation fixup and is a no-op on other\r
   instruction sets. This is used to re-relocated the image into the EFI virtual\r
   space for runtime calls.\r
 \r
@@ -84,5 +84,22 @@ PeHotRelocateImageEx (
   IN UINT64      Adjust\r
   )\r
 {\r
-  return RETURN_UNSUPPORTED;\r
+  UINT64      *F64;\r
+\r
+  switch ((*Reloc) >> 12) {\r
+    case EFI_IMAGE_REL_BASED_DIR64:\r
+      F64 = (UINT64 *) Fixup;\r
+      *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));\r
+      if (*(UINT64 *)(*FixupData) == *F64) {\r
+        *F64  = *F64 + (UINT64) Adjust;\r
+      }\r
+\r
+      *FixupData = *FixupData + sizeof(UINT64);\r
+      break;\r
+\r
+    default:\r
+      return RETURN_UNSUPPORTED;\r
+  }\r
\r
+  return RETURN_SUCCESS;\r
 }\r
index 1e6cc34745cc0f70d85e05e42d86e474250ff29c..30db3e35c519428b25c57bdd507b449ecfc8424d 100644 (file)
@@ -1,6 +1,7 @@
-/*++\r
+/**@file\r
+  x64 Specific relocation fixups.\r
 \r
-Copyright 2005, Intel Corporation                                                         \r
+Copyright (c) 2005 - 2006 Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -9,48 +10,30 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
-\r
-Module Name:\r
-\r
-  PeCoffLoaderEx.c\r
-\r
-Abstract:\r
-\r
-  x64 Specific relocation fixups\r
-\r
-Revision History\r
-\r
---*/\r
+**/\r
 \r
 #include <Common/UefiBaseTypes.h>\r
 #include <Common/EfiImage.h>\r
 #include <Library/PeCoffLib.h>\r
 \r
+/**\r
+  Performs an x64 specific relocation fixup\r
 \r
-\r
-\r
+  @param Reloc        Pointer to the relocation record\r
+  @param Fixup        Pointer to the address to fix up\r
+  @param FixupData    Pointer to a buffer to log the fixups\r
+  @param Adjust       The offset to adjust the fixup\r
+  \r
+  @retval RETURN_SUCCESS      Success to perform relocation\r
+  @retval RETURN_UNSUPPORTED  Unsupported.\r
+**/\r
 RETURN_STATUS\r
 PeCoffLoaderRelocateImageEx (\r
-  IN UINT16      *Reloc,\r
-  IN OUT CHAR8   *Fixup, \r
-  IN OUT CHAR8   **FixupData,\r
-  IN UINT64      Adjust\r
+  IN     UINT16       *Reloc,\r
+  IN OUT CHAR8        *Fixup, \r
+  IN OUT CHAR8        **FixupData,\r
+  IN     UINT64       Adjust\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Performs an x64 specific relocation fixup\r
-\r
-Arguments:\r
-  Reloc      - Pointer to the relocation record\r
-  Fixup      - Pointer to the address to fix up\r
-  FixupData  - Pointer to a buffer to log the fixups\r
-  Adjust     - The offset to adjust the fixup\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
 {\r
   UINT64      *F64;\r
 \r