TianoCore EDK2 master
Loading...
Searching...
No Matches
Elf32Lib.c File Reference
#include "ElfLibInternal.h"

Go to the source code of this file.

Functions

Elf32_ShdrGetElf32SectionByIndex (IN UINT8 *ImageBase, IN UINT32 Index)
 
Elf32_PhdrGetElf32SegmentByIndex (IN UINT8 *ImageBase, IN UINT32 Index)
 
Elf32_ShdrGetElf32SectionByRange (IN UINT8 *ImageBase, IN UINT32 Offset, IN UINT32 Size)
 
EFI_STATUS ProcessRelocation32 (IN Elf32_Rela *Rela, IN UINT32 RelaSize, IN UINT32 RelaEntrySize, IN UINT32 RelaType, IN INTN Delta, IN BOOLEAN DynamicLinking)
 
EFI_STATUS RelocateElf32Dynamic (IN ELF_IMAGE_CONTEXT *ElfCt)
 
EFI_STATUS RelocateElf32Sections (IN ELF_IMAGE_CONTEXT *ElfCt)
 
EFI_STATUS LoadElf32Image (IN ELF_IMAGE_CONTEXT *ElfCt)
 

Detailed Description

ELF library

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

Definition in file Elf32Lib.c.

Function Documentation

◆ GetElf32SectionByIndex()

Elf32_Shdr * GetElf32SectionByIndex ( IN UINT8 *  ImageBase,
IN UINT32  Index 
)

Return the section header specified by Index.

Parameters
ImageBaseThe image base.
IndexThe section index.
Returns
Pointer to the section header.

Definition at line 20 of file Elf32Lib.c.

◆ GetElf32SectionByRange()

Elf32_Shdr * GetElf32SectionByRange ( IN UINT8 *  ImageBase,
IN UINT32  Offset,
IN UINT32  Size 
)

Return the section header specified by the range.

Parameters
ImageBaseThe image base.
OffsetThe section offset.
SizeThe section size.
Returns
Pointer to the section header.

Definition at line 69 of file Elf32Lib.c.

◆ GetElf32SegmentByIndex()

Elf32_Phdr * GetElf32SegmentByIndex ( IN UINT8 *  ImageBase,
IN UINT32  Index 
)

Return the segment header specified by Index.

Parameters
ImageBaseThe image base.
IndexThe segment index.
Returns
Pointer to the segment header.

Definition at line 44 of file Elf32Lib.c.

◆ LoadElf32Image()

EFI_STATUS LoadElf32Image ( IN ELF_IMAGE_CONTEXT ElfCt)

Load ELF image which has 32-bit architecture.

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_SUCCESSELF binary is loaded successfully.
OthersLoading ELF binary fails.

Definition at line 430 of file Elf32Lib.c.

◆ ProcessRelocation32()

EFI_STATUS ProcessRelocation32 ( IN Elf32_Rela Rela,
IN UINT32  RelaSize,
IN UINT32  RelaEntrySize,
IN UINT32  RelaType,
IN INTN  Delta,
IN BOOLEAN  DynamicLinking 
)

Fix up the image based on the relocation entries.

Parameters
RelaRelocation entries.
RelaSizeTotal size of relocation entries.
RelaEntrySizeRelocation entry size.
RelaTypeType of relocation entry.
DeltaThe delta between preferred image base and the actual image base.
DynamicLinkingTRUE when fixing up according to dynamic relocation.
Return values
EFI_SUCCESSThe image fix up is processed successfully.

Definition at line 106 of file Elf32Lib.c.

◆ RelocateElf32Dynamic()

EFI_STATUS RelocateElf32Dynamic ( IN ELF_IMAGE_CONTEXT ElfCt)

Relocate the DYN type image.

Parameters
ElfCtPoint to image context.
Return values
EFI_SUCCESSThe relocation succeeds.
EFI_UNSUPPORTEDThe image doesn't contain a dynamic section.

Definition at line 205 of file Elf32Lib.c.

◆ RelocateElf32Sections()

EFI_STATUS RelocateElf32Sections ( IN ELF_IMAGE_CONTEXT ElfCt)

Relocate all sections in a ELF image.

Parameters
[in]ElfCtELF image context pointer.
Return values
EFI_UNSUPPORTEDRelocation is not supported.
EFI_SUCCESSELF image was relocated successfully.

Definition at line 349 of file Elf32Lib.c.