]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/CCode/Source/PeCoffLoader/X64/PeCoffLoaderEx.c
Handle new relocation type EFI_IMAGE_REL_BASED_DIR64 for X64.
[mirror_edk2.git] / Tools / CCode / Source / PeCoffLoader / X64 / PeCoffLoaderEx.c
1 /**@file
2 x64 Specific relocation fixups.
3
4 Copyright (c) 2005 - 2006 Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include <Common/UefiBaseTypes.h>
16 #include <Common/EfiImage.h>
17 #include <Library/PeCoffLib.h>
18
19 /**
20 Performs an x64 specific relocation fixup
21
22 @param Reloc Pointer to the relocation record
23 @param Fixup Pointer to the address to fix up
24 @param FixupData Pointer to a buffer to log the fixups
25 @param Adjust The offset to adjust the fixup
26
27 @retval RETURN_SUCCESS Success to perform relocation
28 @retval RETURN_UNSUPPORTED Unsupported.
29 **/
30 RETURN_STATUS
31 PeCoffLoaderRelocateImageEx (
32 IN UINT16 *Reloc,
33 IN OUT CHAR8 *Fixup,
34 IN OUT CHAR8 **FixupData,
35 IN UINT64 Adjust
36 )
37 {
38 UINT64 *F64;
39
40 switch ((*Reloc) >> 12) {
41
42 case EFI_IMAGE_REL_BASED_DIR64:
43 F64 = (UINT64 *) Fixup;
44 *F64 = *F64 + (UINT64) Adjust;
45 if (*FixupData != NULL) {
46 *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));
47 *(UINT64 *)(*FixupData) = *F64;
48 *FixupData = *FixupData + sizeof(UINT64);
49 }
50 break;
51
52 default:
53 return RETURN_UNSUPPORTED;
54 }
55
56 return RETURN_SUCCESS;
57 }