TianoCore EDK2 master
|
#include <Base.h>
#include <Library/PeCoffLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/PeCoffExtraActionLib.h>
#include <IndustryStandard/PeImage.h>
Go to the source code of this file.
Macros | |
#define | RV_X(x, s, n) (((x) >> (s)) & ((1<<(n))-1)) |
#define | RISCV_IMM_BITS 12 |
#define | RISCV_IMM_REACH (1LL<<RISCV_IMM_BITS) |
#define | RISCV_CONST_HIGH_PART(VALUE) (((VALUE) + (RISCV_IMM_REACH/2)) & ~(RISCV_IMM_REACH-1)) |
Functions | |
RETURN_STATUS | PeCoffLoaderRelocateImageEx (IN UINT16 *Reloc, IN OUT CHAR8 *Fixup, IN OUT CHAR8 **FixupData, IN UINT64 Adjust) |
RETURN_STATUS | PeHotRelocateImageEx (IN UINT16 *Reloc, IN OUT CHAR8 *Fixup, IN OUT CHAR8 **FixupData, IN UINT64 Adjust) |
BOOLEAN | PeCoffLoaderImageFormatSupported (IN UINT16 Machine) |
UINT16 | PeCoffLoaderGetPeHeaderMagicValue (IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr) |
RETURN_STATUS | PeCoffLoaderGetPeHeader (IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr) |
VOID * | PeCoffLoaderImageAddress (IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, IN UINTN Address, IN UINTN TeStrippedOffset) |
Declaration of internal functions in PE/COFF Lib.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file BasePeCoffLibInternals.h.
#define RISCV_CONST_HIGH_PART | ( | VALUE | ) | (((VALUE) + (RISCV_IMM_REACH/2)) & ~(RISCV_IMM_REACH-1)) |
Definition at line 26 of file BasePeCoffLibInternals.h.
#define RISCV_IMM_BITS 12 |
Definition at line 24 of file BasePeCoffLibInternals.h.
#define RISCV_IMM_REACH (1LL<<RISCV_IMM_BITS) |
Definition at line 25 of file BasePeCoffLibInternals.h.
#define RV_X | ( | x, | |
s, | |||
n | |||
) | (((x) >> (s)) & ((1<<(n))-1)) |
Definition at line 23 of file BasePeCoffLibInternals.h.
RETURN_STATUS PeCoffLoaderGetPeHeader | ( | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT * | ImageContext, |
OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION | Hdr | ||
) |
Retrieves the PE or TE Header from a PE/COFF or TE image.
ImageContext | The context of the image being loaded. |
Hdr | The buffer in which to return the PE32, PE32+, or TE header. |
RETURN_SUCCESS | The PE or TE Header is read. |
Other | The error status from reading the PE/COFF or TE image using the ImageRead function. |
Retrieves the PE or TE Header from a PE/COFF or TE image.
Caution: This function may receive untrusted input. PE/COFF image is external input, so this routine will also done many checks in PE image to make sure PE image DosHeader, PeOptionHeader, SizeOfHeader, Section Data Region and Security Data Region be in PE image range.
ImageContext | The context of the image being loaded. |
Hdr | The buffer in which to return the PE32, PE32+, or TE header. |
RETURN_SUCCESS | The PE or TE Header is read. |
Other | The error status from reading the PE/COFF or TE image using the ImageRead function. |
Definition at line 61 of file BasePeCoff.c.
UINT16 PeCoffLoaderGetPeHeaderMagicValue | ( | IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION | Hdr | ) |
Retrieves the magic value from the PE/COFF header.
Hdr | The buffer in which to return the PE32, PE32+, or TE header. |
VOID * PeCoffLoaderImageAddress | ( | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT * | ImageContext, |
IN UINTN | Address, | ||
IN UINTN | TeStrippedOffset | ||
) |
Converts an image address to the loaded address.
ImageContext | The context of the image being loaded. |
Address | The address to be converted to the loaded address. |
TeStrippedOffset | Stripped offset for TE image. |
Definition at line 907 of file BasePeCoff.c.
BOOLEAN PeCoffLoaderImageFormatSupported | ( | IN UINT16 | Machine | ) |
Returns TRUE if the machine type of PE/COFF image is supported. Supported does not mean the image can be executed it means the PE/COFF loader supports loading and relocating of the image type. It's up to the caller to support the entry point.
Machine | Machine type from the PE Header. |
Returns TRUE if the machine type of PE/COFF image is supported. Supported does not mean the image can be executed it means the PE/COFF loader supports loading and relocating of the image type. It's up to the caller to support the entry point.
[in] | Machine | Machine type from the PE Header. |
Returns TRUE if the machine type of PE/COFF image is supported. Supported does not mean the image can be executed it means the PE/COFF loader supports loading and relocating of the image type. It's up to the caller to support the entry point.
The IA32/X64 version PE/COFF loader/relocater both support IA32, X64 and EBC images.
Machine | The machine type from the PE Header. |
Definition at line 179 of file PeCoffLoaderEx.c.
RETURN_STATUS PeCoffLoaderRelocateImageEx | ( | IN UINT16 * | Reloc, |
IN OUT CHAR8 * | Fixup, | ||
IN OUT CHAR8 ** | FixupData, | ||
IN UINT64 | Adjust | ||
) |
Performs an Itanium-based specific relocation fixup and is a no-op on other instruction sets.
Reloc | The pointer to the relocation record. |
Fixup | The pointer to the address to fix up. |
FixupData | The pointer to a buffer to log the fixups. |
Adjust | The offset to adjust the fixup. |
Performs an ARM-based specific relocation fixup and is a no-op on other instruction sets.
Reloc | The pointer to the relocation record. |
Fixup | The pointer to the address to fix up. |
FixupData | The pointer to a buffer to log the fixups. |
Adjust | The offset to adjust the fixup. |
Performs an LoongArch specific relocation fixup and is a no-op on other instruction sets.
[in] | Reloc | Pointer to the relocation record. |
[in,out] | Fixup | Pointer to the address to fix up. |
[in,out] | FixupData | Pointer to a buffer to log the fixups. |
[in] | Adjust | The offset to adjust the fixup. |
Performs an RISC-V specific relocation fixup and is a no-op on other instruction sets. RISC-V splits 32-bit fixup into 20bit and 12-bit with two relocation types. We have to know the lower 12-bit fixup first then we can deal carry over on high 20-bit fixup. So we log the high 20-bit in FixupData.
Reloc | The pointer to the relocation record. |
Fixup | The pointer to the address to fix up. |
FixupData | The pointer to a buffer to log the fixups. |
Adjust | The offset to adjust the fixup. |
Definition at line 131 of file PeCoffLoaderEx.c.
RETURN_STATUS PeHotRelocateImageEx | ( | IN UINT16 * | Reloc, |
IN OUT CHAR8 * | Fixup, | ||
IN OUT CHAR8 ** | FixupData, | ||
IN UINT64 | Adjust | ||
) |
Performs an Itanium-based specific re-relocation fixup and is a no-op on other instruction sets. This is used to re-relocated the image into the EFI virtual space for runtime calls.
Reloc | The pointer to the relocation record. |
Fixup | The pointer to the address to fix up. |
FixupData | The pointer to a buffer to log the fixups. |
Adjust | The offset to adjust the fixup. |
Performs an ARM-based specific re-relocation fixup and is a no-op on other instruction sets. This is used to re-relocated the image into the EFI virtual space for runtime calls.
Reloc | The pointer to the relocation record. |
Fixup | The pointer to the address to fix up. |
FixupData | The pointer to a buffer to log the fixups. |
Adjust | The offset to adjust the fixup. |
Performs an LOONGARCH-based specific re-relocation fixup and is a no-op on other instruction sets. This is used to re-relocated the image into the EFI virtual space for runtime calls.
[in] | Reloc | The pointer to the relocation record. |
[in,out] | Fixup | The pointer to the address to fix up. |
[in,out] | FixupData | The pointer to a buffer to log the fixups. |
[in] | Adjust | The offset to adjust the fixup. |
Definition at line 204 of file PeCoffLoaderEx.c.