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) |
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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. |
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. |
References EFI_IMAGE_DOS_HEADER::e_lfanew, EFI_IMAGE_DOS_HEADER::e_magic, EFI_IMAGE_DIRECTORY_ENTRY_SECURITY, EFI_IMAGE_DOS_SIGNATURE, EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC, EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC, EFI_IMAGE_NT_SIGNATURE, EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES, EFI_IMAGE_SIZEOF_SECTION_HEADER, EFI_TE_IMAGE_HEADER_SIGNATURE, FALSE, IMAGE_ERROR_IMAGE_READ, IMAGE_ERROR_INVALID_MACHINE_TYPE, IMAGE_ERROR_UNSUPPORTED, PeCoffLoaderAdjustOffsetForTeImage(), PeCoffLoaderGetPeHeaderMagicValue(), PeCoffLoaderImageFormatSupported(), EFI_IMAGE_SECTION_HEADER::PointerToRawData, RETURN_ERROR, RETURN_SUCCESS, RETURN_UNSUPPORTED, EFI_IMAGE_SECTION_HEADER::SizeOfRawData, TRUE, and EFI_IMAGE_SECTION_HEADER::VirtualAddress.
Referenced by PeCoffLoaderGetImageInfo().
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. |
EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+
References EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC, EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC, and IMAGE_FILE_MACHINE_IA64.
Referenced by PeCoffLoaderGetImageInfo(), PeCoffLoaderGetPeHeader(), PeCoffLoaderLoadImage(), PeCoffLoaderRelocateImage(), and PeCoffLoaderRelocateImageForRuntime().
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. |
References IMAGE_ERROR_INVALID_IMAGE_ADDRESS, and NULL.
Referenced by PeCoffLoaderLoadImage(), and PeCoffLoaderRelocateImage().
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. |
The itanium version PE/COFF loader/relocater supports itanium and EBC image.
Machine | Machine type from the PE Header. |
FALSE unrecoganized machine type of image.
The IA32/X64 version PE/COFF loader/relocater both support IA32, X64 and EBC images.
Machine | The machine type from the PE Header. |
References FALSE, IMAGE_FILE_MACHINE_ARM64, IMAGE_FILE_MACHINE_ARMTHUMB_MIXED, IMAGE_FILE_MACHINE_EBC, IMAGE_FILE_MACHINE_I386, IMAGE_FILE_MACHINE_IA64, IMAGE_FILE_MACHINE_X64, and TRUE.
Referenced by PeCoffLoaderGetPeHeader().
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. |
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. |
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. |
RETURN_SUCCESS | Succeed to fix the relocation entry. | |
RETURN_UNSUPPOTED | Unrecoganized relocation entry. |
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. |
References ALIGN_POINTER, ASSERT, CopyMem(), EFI_IMAGE_REL_BASED_ARM_MOV32A, EFI_IMAGE_REL_BASED_ARM_MOV32T, EFI_IMAGE_REL_BASED_DIR64, EFI_IMAGE_REL_BASED_IA64_IMM64, EXT_IMM64, FALSE, IMM64_IC_INST_WORD_POS_X, IMM64_IC_INST_WORD_X, IMM64_IC_SIZE_X, IMM64_IC_VAL_POS_X, IMM64_IMM41A_INST_WORD_POS_X, IMM64_IMM41A_INST_WORD_X, IMM64_IMM41A_SIZE_X, IMM64_IMM41A_VAL_POS_X, IMM64_IMM41B_INST_WORD_POS_X, IMM64_IMM41B_INST_WORD_X, IMM64_IMM41B_SIZE_X, IMM64_IMM41B_VAL_POS_X, IMM64_IMM41C_INST_WORD_POS_X, IMM64_IMM41C_INST_WORD_X, IMM64_IMM41C_SIZE_X, IMM64_IMM41C_VAL_POS_X, IMM64_IMM5C_INST_WORD_POS_X, IMM64_IMM5C_INST_WORD_X, IMM64_IMM5C_SIZE_X, IMM64_IMM5C_VAL_POS_X, IMM64_IMM7B_INST_WORD_POS_X, IMM64_IMM7B_INST_WORD_X, IMM64_IMM7B_SIZE_X, IMM64_IMM7B_VAL_POS_X, IMM64_IMM9D_INST_WORD_POS_X, IMM64_IMM9D_INST_WORD_X, IMM64_IMM9D_SIZE_X, IMM64_IMM9D_VAL_POS_X, IMM64_SIGN_INST_WORD_POS_X, IMM64_SIGN_INST_WORD_X, IMM64_SIGN_SIZE_X, IMM64_SIGN_VAL_POS_X, INS_IMM64, NULL, RETURN_SUCCESS, RETURN_UNSUPPORTED, ThumbMovwMovtImmediateAddress(), and ThumbMovwMovtImmediatePatch().
Referenced by PeCoffLoaderRelocateImage().
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. |
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. |
Reloc | Ponter to baes of the input stream | |
Fixup | Offset to the start of the buffer | |
FixupData | The number of bytes to copy into the buffer | |
Adjust | Location to place results of read |
RETURN_SUCCESS | Data is read from FileOffset from the Handle into the buffer. | |
RETURN_UNSUPPORTED | Un-recoganized relocation entry type. |
References ALIGN_POINTER, ASSERT, DEBUG, EFI_D_ERROR, EFI_IMAGE_REL_BASED_ARM_MOV32A, EFI_IMAGE_REL_BASED_ARM_MOV32T, EFI_IMAGE_REL_BASED_DIR64, EFI_IMAGE_REL_BASED_IA64_IMM64, EXT_IMM64, FALSE, IMM64_IC_INST_WORD_POS_X, IMM64_IC_INST_WORD_X, IMM64_IC_SIZE_X, IMM64_IC_VAL_POS_X, IMM64_IMM41A_INST_WORD_POS_X, IMM64_IMM41A_INST_WORD_X, IMM64_IMM41A_SIZE_X, IMM64_IMM41A_VAL_POS_X, IMM64_IMM41B_INST_WORD_POS_X, IMM64_IMM41B_INST_WORD_X, IMM64_IMM41B_SIZE_X, IMM64_IMM41B_VAL_POS_X, IMM64_IMM41C_INST_WORD_POS_X, IMM64_IMM41C_INST_WORD_X, IMM64_IMM41C_SIZE_X, IMM64_IMM41C_VAL_POS_X, IMM64_IMM5C_INST_WORD_POS_X, IMM64_IMM5C_INST_WORD_X, IMM64_IMM5C_SIZE_X, IMM64_IMM5C_VAL_POS_X, IMM64_IMM7B_INST_WORD_POS_X, IMM64_IMM7B_INST_WORD_X, IMM64_IMM7B_SIZE_X, IMM64_IMM7B_VAL_POS_X, IMM64_IMM9D_INST_WORD_POS_X, IMM64_IMM9D_INST_WORD_X, IMM64_IMM9D_SIZE_X, IMM64_IMM9D_VAL_POS_X, IMM64_SIGN_INST_WORD_POS_X, IMM64_SIGN_INST_WORD_X, IMM64_SIGN_SIZE_X, IMM64_SIGN_VAL_POS_X, INS_IMM64, ReadUnaligned64(), RETURN_SUCCESS, RETURN_UNSUPPORTED, ThumbMovwMovtImmediateAddress(), and ThumbMovwMovtImmediatePatch().
Referenced by PeCoffLoaderRelocateImageForRuntime().