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