]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h
bf9e18bef42dcf29de74740daa238353b3fb310d
[mirror_edk2.git] / MdePkg / Library / BasePeCoffLib / BasePeCoffLibInternals.h
1 /** @file
2 Declaration of internal functions in PE/COFF Lib.
3
4 Copyright (c) 2006, Intel Corporation<BR>
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: BasePeCoffLibInternals.h
14
15 **/
16
17 #ifndef __BASE_PECOFF_LIB_INTERNALS__
18 #define __BASE_PECOFF_LIB_INTERNALS__
19
20 //
21 // Include common header file for this module.
22 //
23 #include "CommonHeader.h"
24
25 /**
26 Performs an Itanium-based specific relocation fixup and is a no-op on other
27 instruction sets.
28
29 @param Reloc Pointer to the relocation record.
30 @param Fixup Pointer to the address to fix up.
31 @param FixupData Pointer to a buffer to log the fixups.
32 @param Adjust The offset to adjust the fixup.
33
34 @return Status code.
35
36 **/
37 RETURN_STATUS
38 PeCoffLoaderRelocateImageEx (
39 IN UINT16 *Reloc,
40 IN OUT CHAR8 *Fixup,
41 IN OUT CHAR8 **FixupData,
42 IN UINT64 Adjust
43 );
44
45
46 /**
47 Performs an Itanium-based specific re-relocation fixup and is a no-op on other
48 instruction sets. This is used to re-relocated the image into the EFI virtual
49 space for runtime calls.
50
51 @param Reloc Pointer to the relocation record.
52 @param Fixup Pointer to the address to fix up.
53 @param FixupData Pointer to a buffer to log the fixups.
54 @param Adjust The offset to adjust the fixup.
55
56 @return Status code.
57
58 **/
59 RETURN_STATUS
60 PeHotRelocateImageEx (
61 IN UINT16 *Reloc,
62 IN OUT CHAR8 *Fixup,
63 IN OUT CHAR8 **FixupData,
64 IN UINT64 Adjust
65 );
66
67
68 /**
69 Returns TRUE if the machine type of PE/COFF image is supported. Supported
70 does not mean the image can be executed it means the PE/COFF loader supports
71 loading and relocating of the image type. It's up to the caller to support
72 the entry point.
73
74 @param Machine Machine type from the PE Header.
75
76 @return TRUE if this PE/COFF loader can load the image
77
78 **/
79 BOOLEAN
80 PeCoffLoaderImageFormatSupported (
81 IN UINT16 Machine
82 );
83
84 /**
85 Retrieves the magic value from the PE/COFF header.
86
87 @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
88
89 @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32
90 @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+
91
92 **/
93 UINT16
94 PeCoffLoaderGetPeHeaderMagicValue (
95 IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
96 );
97
98 /**
99 Retrieves the PE or TE Header from a PE/COFF or TE image.
100
101 @param ImageContext The context of the image being loaded.
102 @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
103
104 @retval RETURN_SUCCESS The PE or TE Header is read.
105 @retval Other The error status from reading the PE/COFF or TE image using the ImageRead function.
106
107 **/
108 RETURN_STATUS
109 PeCoffLoaderGetPeHeader (
110 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
111 OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
112 );
113
114 /**
115 Converts an image address to the loaded address.
116
117 @param ImageContext The context of the image being loaded.
118 @param Address The address to be converted to the loaded address.
119
120 @return The converted address or NULL if the address can not be converted.
121
122 **/
123 VOID *
124 PeCoffLoaderImageAddress (
125 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
126 IN UINTN Address
127 );
128
129 #endif