TianoCore EDK2 master
Loading...
Searching...
No Matches
ElfLib.h File Reference
#include <PiPei.h>

Go to the source code of this file.

Data Structures

struct  ELF_IMAGE_CONTEXT
 
struct  SEGMENT_INFO
 

Macros

#define ELF_CLASS32   1
 
#define ELF_CLASS64   2
 
#define ELF_PT_LOAD   1
 

Functions

EFI_STATUS EFIAPI ParseElfImage (IN VOID *ImageBase, OUT ELF_IMAGE_CONTEXT *ElfCt)
 
EFI_STATUS EFIAPI LoadElfImage (IN ELF_IMAGE_CONTEXT *ElfCt)
 
EFI_STATUS EFIAPI GetElfSectionName (IN ELF_IMAGE_CONTEXT *ElfCt, IN UINT32 SectionIndex, OUT CHAR8 **SectionName)
 
EFI_STATUS EFIAPI GetElfSectionPos (IN ELF_IMAGE_CONTEXT *ElfCt, IN UINT32 Index, OUT UINTN *Offset, OUT UINTN *Size)
 

Detailed Description

ELF library

Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file ElfLib.h.

Macro Definition Documentation

◆ ELF_CLASS32

#define ELF_CLASS32   1

Definition at line 14 of file ElfLib.h.

◆ ELF_CLASS64

#define ELF_CLASS64   2

Definition at line 15 of file ElfLib.h.

◆ ELF_PT_LOAD

#define ELF_PT_LOAD   1

Definition at line 17 of file ElfLib.h.

Function Documentation

◆ GetElfSectionName()

EFI_STATUS EFIAPI GetElfSectionName ( IN ELF_IMAGE_CONTEXT ElfCt,
IN UINT32  SectionIndex,
OUT CHAR8 **  SectionName 
)

Get a ELF section name from its index.

Parameters
[in]ElfCtELF image context pointer.
[in]SectionIndexELF section index.
[out]SectionNameThe pointer to the section name.
Return values
EFI_INVALID_PARAMETERElfCt or SecName is NULL.
EFI_NOT_FOUNDCould not find the section.
EFI_SUCCESSSection name was filled successfully.

Definition at line 392 of file ElfLib.c.

◆ GetElfSectionPos()

EFI_STATUS EFIAPI GetElfSectionPos ( IN ELF_IMAGE_CONTEXT ElfCt,
IN UINT32  Index,
OUT UINTN Offset,
OUT UINTN Size 
)

Get the offset and size of x-th ELF section.

Parameters
[in]ElfCtELF image context pointer.
[in]IndexELF section index.
[out]OffsetReturn the offset of the specific section.
[out]SizeReturn the size of the specific section.
Return values
EFI_INVALID_PARAMETERImageBase, Offset or Size is NULL.
EFI_INVALID_PARAMETEREiClass doesn't equal to ELFCLASS32 or ELFCLASS64.
EFI_NOT_FOUNDCould not find the section.
EFI_SUCCESSOffset and Size are returned.

Definition at line 446 of file ElfLib.c.

◆ LoadElfImage()

EFI_STATUS EFIAPI LoadElfImage ( IN ELF_IMAGE_CONTEXT ElfCt)

Load the ELF segments to specified address in ELF header.

This function loads ELF image segments into memory address specified in ELF program header.

Parameters
[in]ElfCtELF image context pointer.
Return values
EFI_INVALID_PARAMETERInput parameters are not valid.
EFI_UNSUPPORTEDUnsupported binary type.
EFI_LOAD_ERRORELF binary loading error.
EFI_SUCCESSELF binary is loaded successfully.

Load the ELF image to Context.ImageAddress.

Context should be initialized by ParseElfImage(). Caller should set Context.ImageAddress to a proper value, either pointing to a new allocated memory whose size equal to Context.ImageSize, or pointing to Context.PreferredImageAddress.

Parameters
[in]ElfCtELF image context pointer.
Return values
EFI_INVALID_PARAMETERInput parameters are not valid.
EFI_UNSUPPORTEDUnsupported binary type.
EFI_LOAD_ERRORELF binary loading error.
EFI_SUCCESSELF binary is loaded successfully.

Definition at line 351 of file ElfLib.c.

◆ ParseElfImage()

EFI_STATUS EFIAPI ParseElfImage ( IN VOID *  ImageBase,
OUT ELF_IMAGE_CONTEXT ElfCt 
)

Parse the ELF image info.

Parameters
[in]ImageBaseMemory address of an image.
[out]ElfCtThe EFL image context pointer.
Return values
EFI_INVALID_PARAMETERInput parameters are not valid.
EFI_UNSUPPORTEDUnsupported binary type.
EFI_LOAD_ERRORELF binary loading error.
EFI_SUCCESSELF binary is loaded successfully.

Parse the ELF image info.

On return, all fields in ElfCt are updated except ImageAddress.

Parameters
[in]ImageBaseMemory address of an image.
[out]ElfCtThe EFL image context pointer.
Return values
EFI_INVALID_PARAMETERInput parameters are not valid.
EFI_UNSUPPORTEDUnsupported binary type.
EFI_LOAD_ERRORELF binary loading error.
EFI_SUCCESSELF binary is loaded successfully.

Definition at line 229 of file ElfLib.c.