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>
21 // Note: Currently only large memory model is supported by UEFI relocation code.
24 Performs an AARCH64-based specific relocation fixup and is a no-op on other
27 @param Reloc The pointer to the relocation record.
28 @param Fixup The pointer to the address to fix up.
29 @param FixupData The pointer to a buffer to log the fixups.
30 @param Adjust The offset to adjust the fixup.
36 PeCoffLoaderRelocateImageEx (
39 IN OUT CHAR8
**FixupData
,
45 switch ((*Reloc
) >> 12) {
47 case EFI_IMAGE_REL_BASED_DIR64
:
48 F64
= (UINT64
*) Fixup
;
49 *F64
= *F64
+ (UINT64
) Adjust
;
50 if (*FixupData
!= NULL
) {
51 *FixupData
= ALIGN_POINTER(*FixupData
, sizeof(UINT64
));
52 *(UINT64
*)(*FixupData
) = *F64
;
53 *FixupData
= *FixupData
+ sizeof(UINT64
);
58 return RETURN_UNSUPPORTED
;
61 return RETURN_SUCCESS
;
65 Returns TRUE if the machine type of PE/COFF image is supported. Supported
66 does not mean the image can be executed it means the PE/COFF loader supports
67 loading and relocating of the image type. It's up to the caller to support
70 @param Machine Machine type from the PE Header.
72 @return TRUE if this PE/COFF loader can load the image
76 PeCoffLoaderImageFormatSupported (
80 if ((Machine
== IMAGE_FILE_MACHINE_ARM64
) || (Machine
== IMAGE_FILE_MACHINE_EBC
)) {
88 Performs an ARM-based specific re-relocation fixup and is a no-op on other
89 instruction sets. This is used to re-relocated the image into the EFI virtual
90 space for runtime calls.
92 @param Reloc The pointer to the relocation record.
93 @param Fixup The pointer to the address to fix up.
94 @param FixupData The pointer to a buffer to log the fixups.
95 @param Adjust The offset to adjust the fixup.
101 PeHotRelocateImageEx (
104 IN OUT CHAR8
**FixupData
,
110 switch ((*Reloc
) >> 12) {
111 case EFI_IMAGE_REL_BASED_DIR64
:
112 Fixup64
= (UINT64
*) Fixup
;
113 *FixupData
= ALIGN_POINTER (*FixupData
, sizeof (UINT64
));
114 if (*(UINT64
*) (*FixupData
) == *Fixup64
) {
115 *Fixup64
= *Fixup64
+ (UINT64
) Adjust
;
118 *FixupData
= *FixupData
+ sizeof (UINT64
);
122 DEBUG ((EFI_D_ERROR
, "PeHotRelocateEx:unknown fixed type\n"));
123 return RETURN_UNSUPPORTED
;
126 return RETURN_SUCCESS
;