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