]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BasePeCoffLib/x64/PeCoffLoaderEx.c
Initial import.
[mirror_edk2.git] / MdePkg / Library / BasePeCoffLib / x64 / PeCoffLoaderEx.c
CommitLineData
878ddf1f 1/** @file\r
2 x64 Specific relocation fixups.\r
3\r
4 Copyright (c) 2006, Intel Corporation\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
12\r
13 Module Name: PeCoffLoaderEx.c\r
14\r
15**/\r
16\r
17\r
18\r
19\r
20/**\r
21 Performs an x64 specific relocation fixup.\r
22\r
23 @param Reloc Pointer to the relocation record\r
24 @param Fixup Pointer to the address to fix up\r
25 @param FixupData Pointer to a buffer to log the fixups\r
26 @param Adjust The offset to adjust the fixup\r
27\r
28**/\r
29RETURN_STATUS\r
30PeCoffLoaderRelocateImageEx (\r
31 IN UINT16 *Reloc,\r
32 IN OUT CHAR8 *Fixup, \r
33 IN OUT CHAR8 **FixupData,\r
34 IN UINT64 Adjust\r
35 )\r
36{\r
37 UINT64 *F64;\r
38\r
39 switch ((*Reloc) >> 12) {\r
40\r
41 case EFI_IMAGE_REL_BASED_DIR64:\r
42 F64 = (UINT64 *) Fixup;\r
43 *F64 = *F64 + (UINT64) Adjust;\r
44 if (*FixupData != NULL) {\r
45 *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));\r
46 *(UINT64 *)(*FixupData) = *F64;\r
47 *FixupData = *FixupData + sizeof(UINT64);\r
48 }\r
49 break;\r
50\r
51 default:\r
52 return RETURN_UNSUPPORTED;\r
53 }\r
54\r
55 return RETURN_SUCCESS;\r
56}\r