2 Specific relocation fixups for ARM architecture.
4 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
6 Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php.
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include "BasePeCoffLibInternals.h"
19 #include <Library/BaseLib.h>
22 // Note: Currently only large memory model is supported by UEFI relocation code.
26 Performs an AARCH64-based specific relocation fixup and is a no-op on other
29 @param Reloc The pointer to the relocation record.
30 @param Fixup The pointer to the address to fix up.
31 @param FixupData The pointer to a buffer to log the fixups.
32 @param Adjust The offset to adjust the fixup.
38 PeCoffLoaderRelocateImageEx (
41 IN OUT CHAR8
**FixupData
,
47 switch ((**Reloc
) >> 12) {
49 case EFI_IMAGE_REL_BASED_DIR64
:
50 F64
= (UINT64
*) Fixup
;
51 *F64
= *F64
+ (UINT64
) Adjust
;
52 if (*FixupData
!= NULL
) {
53 *FixupData
= ALIGN_POINTER(*FixupData
, sizeof(UINT64
));
54 *(UINT64
*)(*FixupData
) = *F64
;
55 *FixupData
= *FixupData
+ sizeof(UINT64
);
60 return RETURN_UNSUPPORTED
;
63 return RETURN_SUCCESS
;
67 Returns TRUE if the machine type of PE/COFF image is supported. Supported
68 does not mean the image can be executed it means the PE/COFF loader supports
69 loading and relocating of the image type. It's up to the caller to support
72 @param Machine Machine type from the PE Header.
74 @return TRUE if this PE/COFF loader can load the image
78 PeCoffLoaderImageFormatSupported (
82 if ((Machine
== IMAGE_FILE_MACHINE_AARCH64
) || (Machine
== IMAGE_FILE_MACHINE_EBC
)) {
90 Performs an ARM-based specific re-relocation fixup and is a no-op on other
91 instruction sets. This is used to re-relocated the image into the EFI virtual
92 space for runtime calls.
94 @param Reloc The pointer to the relocation record.
95 @param Fixup The pointer to the address to fix up.
96 @param FixupData The pointer to a buffer to log the fixups.
97 @param Adjust The offset to adjust the fixup.
103 PeHotRelocateImageEx (
106 IN OUT CHAR8
**FixupData
,
112 switch ((**Reloc
) >> 12) {
113 case EFI_IMAGE_REL_BASED_DIR64
:
114 Fixup64
= (UINT64
*) Fixup
;
115 *FixupData
= ALIGN_POINTER (*FixupData
, sizeof (UINT64
));
116 if (*(UINT64
*) (*FixupData
) == *Fixup64
) {
117 *Fixup64
= *Fixup64
+ (UINT64
) Adjust
;
120 *FixupData
= *FixupData
+ sizeof (UINT64
);
124 DEBUG ((EFI_D_ERROR
, "PeHotRelocateEx:unknown fixed type\n"));
125 return RETURN_UNSUPPORTED
;
128 return RETURN_SUCCESS
;