]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/TianoTools/GenFvImage/X64/PeCoffLoaderEx.c
6bcae272e7a8b6a0369bd194209dc1888d2a4998
[mirror_edk2.git] / Tools / Source / TianoTools / GenFvImage / 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 #define EFI_SPECIFICATION_VERSION 0x00000000
26 #define EDK_RELEASE_VERSION 0x00020000
27 #include <Base.h>
28 #include <Library/PeCoffLib.h>
29 #include <Library/BaseMemoryLib.h>
30
31
32
33
34 RETURN_STATUS
35 PeCoffLoaderRelocateImageEx (
36 IN UINT16 *Reloc,
37 IN OUT CHAR8 *Fixup,
38 IN OUT CHAR8 **FixupData,
39 IN UINT64 Adjust
40 )
41 /*++
42
43 Routine Description:
44 Performs an x64 specific relocation fixup
45
46 Arguments:
47 Reloc - Pointer to the relocation record
48 Fixup - Pointer to the address to fix up
49 FixupData - Pointer to a buffer to log the fixups
50 Adjust - The offset to adjust the fixup
51
52 Returns:
53 None
54
55 --*/
56 {
57 UINT64 *F64;
58
59 switch ((*Reloc) >> 12) {
60
61 case EFI_IMAGE_REL_BASED_DIR64:
62 F64 = (UINT64 *) Fixup;
63 *F64 = *F64 + (UINT64) Adjust;
64 if (*FixupData != NULL) {
65 *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));
66 *(UINT64 *)(*FixupData) = *F64;
67 *FixupData = *FixupData + sizeof(UINT64);
68 }
69 break;
70
71 default:
72 return RETURN_UNSUPPORTED;
73 }
74
75 return RETURN_SUCCESS;
76 }