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