MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h File Reference


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)

Detailed Description

Declaration of internal functions in PE/COFF Lib.

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.


Function Documentation

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.

Parameters:
ImageContext The context of the image being loaded.
Hdr The buffer in which to return the PE32, PE32+, or TE header.
Return values:
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.

Parameters:
ImageContext The context of the image being loaded.
Hdr The buffer in which to return the PE32, PE32+, or TE header.
Return values:
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.

Parameters:
Hdr The buffer in which to return the PE32, PE32+, or TE header.
Returns:
EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32

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.

Parameters:
ImageContext The context of the image being loaded.
Address The address to be converted to the loaded address.
TeStrippedOffset Stripped offset for TE image.
Returns:
The converted address or NULL if the address can not be converted.

References IMAGE_ERROR_INVALID_IMAGE_ADDRESS, and NULL.

Referenced by PeCoffLoaderLoadImage(), and PeCoffLoaderRelocateImage().

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.

Parameters:
Machine Machine type from the PE Header.
Returns:
TRUE if this PE/COFF loader can load the image
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 itanium version PE/COFF loader/relocater supports itanium and EBC image.

Parameters:
Machine Machine type from the PE Header.
Returns:
TRUE if this PE/COFF loader can load the image

FALSE unrecoganized machine type of image.

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.

Parameters:
Machine The machine type from the PE Header.
Returns:
TRUE if this PE/COFF loader can load the image

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.

Parameters:
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.
Returns:
Status code.
Performs an ARM-based specific relocation fixup and is a no-op on other instruction sets.

Parameters:
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.
Returns:
Status code.
Performs an Itanium-based specific relocation fixup.

Parameters:
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 values:
RETURN_SUCCESS Succeed to fix the relocation entry.
RETURN_UNSUPPOTED Unrecoganized relocation entry.
Performs an AARCH64-based specific relocation fixup and is a no-op on other instruction sets.

Parameters:
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.
Returns:
Status code.

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.

Parameters:
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.
Returns:
Status code.
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.

Parameters:
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.
Returns:
Status code.
ImageRead function that operates on a memory buffer whos base is passed into FileHandle.

Parameters:
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 values:
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().


Generated on Thu Sep 24 23:14:23 2015 for MdePkg[ALL] by  doxygen 1.5.7.1