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

Go to the source code of this file.

Functions

Elf64_ShdrGetElf64SectionByIndex (IN UINT8 *ImageBase, IN UINT32 Index)
 
Elf64_PhdrGetElf64SegmentByIndex (IN UINT8 *ImageBase, IN UINT32 Index)
 
Elf64_ShdrGetElf64SectionByRange (IN UINT8 *ImageBase, IN UINT64 Offset, IN UINT64 Size)
 
EFI_STATUS ProcessRelocation64 (IN Elf64_Rela *Rela, IN UINT64 RelaSize, IN UINT64 RelaEntrySize, IN UINT64 RelaType, IN INT64 Delta, IN BOOLEAN DynamicLinking)
 
EFI_STATUS RelocateElf64Dynamic (IN ELF_IMAGE_CONTEXT *ElfCt)
 
EFI_STATUS RelocateElf64Sections (IN ELF_IMAGE_CONTEXT *ElfCt)
 
EFI_STATUS LoadElf64Image (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 Elf64Lib.c.

Function Documentation

◆ GetElf64SectionByIndex()

Elf64_Shdr * GetElf64SectionByIndex ( 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 Elf64Lib.c.

◆ GetElf64SectionByRange()

Elf64_Shdr * GetElf64SectionByRange ( IN UINT8 *  ImageBase,
IN UINT64  Offset,
IN UINT64  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 Elf64Lib.c.

◆ GetElf64SegmentByIndex()

Elf64_Phdr * GetElf64SegmentByIndex ( 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 Elf64Lib.c.

◆ LoadElf64Image()

EFI_STATUS LoadElf64Image ( IN ELF_IMAGE_CONTEXT ElfCt)

Load ELF image which has 64-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 439 of file Elf64Lib.c.

◆ ProcessRelocation64()

EFI_STATUS ProcessRelocation64 ( IN Elf64_Rela Rela,
IN UINT64  RelaSize,
IN UINT64  RelaEntrySize,
IN UINT64  RelaType,
IN INT64  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 Elf64Lib.c.

◆ RelocateElf64Dynamic()

EFI_STATUS RelocateElf64Dynamic ( 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 214 of file Elf64Lib.c.

◆ RelocateElf64Sections()

EFI_STATUS RelocateElf64Sections ( 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 358 of file Elf64Lib.c.