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