]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | x64 Specific relocation fixups.\r | |
3 | \r | |
265c22cc | 4 | Copyright (c) 2005 - 2006 Intel Corporation. <BR>\r |
5 | All rights reserved. This program and the accompanying materials \r | |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
878ddf1f | 12 | \r |
13 | **/\r | |
14 | \r | |
878ddf1f | 15 | /**\r |
16 | Performs an x64 specific relocation fixup.\r | |
17 | \r | |
4ba61e5e | 18 | @param Reloc Pointer to the relocation record\r |
19 | @param Fixup Pointer to the address to fix up\r | |
20 | @param FixupData Pointer to a buffer to log the fixups\r | |
21 | @param Adjust The offset to adjust the fixup\r | |
878ddf1f | 22 | \r |
265c22cc | 23 | @retval RETURN_SUCCESS Success to perform relocation\r |
24 | @retval RETURN_UNSUPPORTED Unsupported.\r | |
878ddf1f | 25 | **/\r |
26 | RETURN_STATUS\r | |
27 | PeCoffLoaderRelocateImageEx (\r | |
265c22cc | 28 | IN UINT16 *Reloc,\r |
29 | IN OUT CHAR8 *Fixup, \r | |
30 | IN OUT CHAR8 **FixupData,\r | |
31 | IN UINT64 Adjust\r | |
878ddf1f | 32 | )\r |
33 | {\r | |
2ce31132 | 34 | return RETURN_UNSUPPORTED;\r |
35 | }\r | |
36 | \r | |
37 | /**\r | |
38 | Returns TRUE if the machine type of PE/COFF image is supported. Supported \r | |
39 | does not mean the image can be executed it means the PE/COFF loader supports\r | |
40 | loading and relocating of the image type. It's up to the caller to support\r | |
41 | the entry point. \r | |
42 | \r | |
43 | This function implies the basic PE/COFF loader/relocator supports IA32, EBC,\r | |
44 | & X64 images. Calling the entry point in a correct mannor is up to the \r | |
45 | consumer of this library.\r | |
46 | \r | |
47 | @param Machine Machine type from the PE Header.\r | |
48 | \r | |
49 | @return TRUE if this PE/COFF loader can load the image\r | |
50 | \r | |
51 | **/\r | |
52 | BOOLEAN\r | |
53 | PeCoffLoaderImageFormatSupported (\r | |
54 | IN UINT16 Machine\r | |
55 | )\r | |
56 | {\r | |
57 | if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) || \r | |
58 | (Machine == EFI_IMAGE_MACHINE_EBC)) {\r | |
59 | return TRUE; \r | |
878ddf1f | 60 | }\r |
61 | \r | |
2ce31132 | 62 | return FALSE;\r |
63 | }\r | |
64 | \r | |
65 | \r | |
66 | /**\r | |
265c22cc | 67 | Performs an X64 specific re-relocation fixup and is a no-op on other\r |
2ce31132 | 68 | instruction sets. This is used to re-relocated the image into the EFI virtual\r |
69 | space for runtime calls.\r | |
70 | \r | |
71 | @param Reloc Pointer to the relocation record.\r | |
72 | @param Fixup Pointer to the address to fix up.\r | |
73 | @param FixupData Pointer to a buffer to log the fixups.\r | |
74 | @param Adjust The offset to adjust the fixup.\r | |
75 | \r | |
76 | @return Status code.\r | |
77 | \r | |
78 | **/\r | |
79 | RETURN_STATUS\r | |
80 | PeHotRelocateImageEx (\r | |
81 | IN UINT16 *Reloc,\r | |
82 | IN OUT CHAR8 *Fixup,\r | |
83 | IN OUT CHAR8 **FixupData,\r | |
84 | IN UINT64 Adjust\r | |
85 | )\r | |
86 | {\r | |
265c22cc | 87 | UINT64 *F64;\r |
88 | \r | |
89 | switch ((*Reloc) >> 12) {\r | |
90 | case EFI_IMAGE_REL_BASED_DIR64:\r | |
91 | F64 = (UINT64 *) Fixup;\r | |
92 | *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));\r | |
93 | if (*(UINT64 *)(*FixupData) == *F64) {\r | |
94 | *F64 = *F64 + (UINT64) Adjust;\r | |
95 | }\r | |
96 | \r | |
97 | *FixupData = *FixupData + sizeof(UINT64);\r | |
98 | break;\r | |
99 | \r | |
100 | default:\r | |
101 | return RETURN_UNSUPPORTED;\r | |
102 | }\r | |
103 | \r | |
104 | return RETURN_SUCCESS;\r | |
878ddf1f | 105 | }\r |