VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/UefiPayloadPkg/PayloadLoaderPeim/ElfLib.h@ 107365

Last change on this file since 107365 was 99404, checked in by vboxsync, 2 years ago

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1/** @file
2 ELF library
3
4 Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
9#ifndef ELF_LIB_H_
10#define ELF_LIB_H_
11
12#include <PiPei.h>
13
14#define ELF_CLASS32 1
15#define ELF_CLASS64 2
16
17#define ELF_PT_LOAD 1
18
19typedef struct {
20 RETURN_STATUS ParseStatus; ///< Return the status after ParseElfImage().
21 UINT8 *FileBase; ///< The source location in memory.
22 UINTN FileSize; ///< The size including sections that don't require loading.
23 UINT8 *PreferredImageAddress; ///< The preferred image to be loaded. No relocation is needed if loaded to this address.
24 BOOLEAN ReloadRequired; ///< The image needs a new memory location for running.
25 UINT8 *ImageAddress; ///< The destination memory address set by caller.
26 UINTN ImageSize; ///< The memory size for loading and execution.
27 UINT32 EiClass;
28 UINT32 ShNum;
29 UINT32 PhNum;
30 UINTN ShStrOff;
31 UINTN ShStrLen;
32 UINTN EntryPoint; ///< Return the actual entry point after LoadElfImage().
33} ELF_IMAGE_CONTEXT;
34
35typedef struct {
36 UINT32 PtType;
37 UINTN Offset;
38 UINTN Length;
39 UINTN MemLen;
40 UINTN MemAddr;
41 UINTN Alignment;
42} SEGMENT_INFO;
43
44/**
45 Parse the ELF image info.
46
47 @param[in] ImageBase Memory address of an image.
48 @param[out] ElfCt The EFL image context pointer.
49
50 @retval EFI_INVALID_PARAMETER Input parameters are not valid.
51 @retval EFI_UNSUPPORTED Unsupported binary type.
52 @retval EFI_LOAD_ERROR ELF binary loading error.
53 @retval EFI_SUCCESS ELF binary is loaded successfully.
54**/
55EFI_STATUS
56EFIAPI
57ParseElfImage (
58 IN VOID *ImageBase,
59 OUT ELF_IMAGE_CONTEXT *ElfCt
60 );
61
62/**
63 Load the ELF segments to specified address in ELF header.
64
65 This function loads ELF image segments into memory address specified
66 in ELF program header.
67
68 @param[in] ElfCt ELF image context pointer.
69
70 @retval EFI_INVALID_PARAMETER Input parameters are not valid.
71 @retval EFI_UNSUPPORTED Unsupported binary type.
72 @retval EFI_LOAD_ERROR ELF binary loading error.
73 @retval EFI_SUCCESS ELF binary is loaded successfully.
74**/
75EFI_STATUS
76EFIAPI
77LoadElfImage (
78 IN ELF_IMAGE_CONTEXT *ElfCt
79 );
80
81/**
82 Get a ELF section name from its index.
83
84 @param[in] ElfCt ELF image context pointer.
85 @param[in] SectionIndex ELF section index.
86 @param[out] SectionName The pointer to the section name.
87
88 @retval EFI_INVALID_PARAMETER ElfCt or SecName is NULL.
89 @retval EFI_NOT_FOUND Could not find the section.
90 @retval EFI_SUCCESS Section name was filled successfully.
91**/
92EFI_STATUS
93EFIAPI
94GetElfSectionName (
95 IN ELF_IMAGE_CONTEXT *ElfCt,
96 IN UINT32 SectionIndex,
97 OUT CHAR8 **SectionName
98 );
99
100/**
101 Get the offset and size of x-th ELF section.
102
103 @param[in] ElfCt ELF image context pointer.
104 @param[in] Index ELF section index.
105 @param[out] Offset Return the offset of the specific section.
106 @param[out] Size Return the size of the specific section.
107
108 @retval EFI_INVALID_PARAMETER ImageBase, Offset or Size is NULL.
109 @retval EFI_INVALID_PARAMETER EiClass doesn't equal to ELFCLASS32 or ELFCLASS64.
110 @retval EFI_NOT_FOUND Could not find the section.
111 @retval EFI_SUCCESS Offset and Size are returned.
112**/
113EFI_STATUS
114EFIAPI
115GetElfSectionPos (
116 IN ELF_IMAGE_CONTEXT *ElfCt,
117 IN UINT32 Index,
118 OUT UINTN *Offset,
119 OUT UINTN *Size
120 );
121
122#endif /* ELF_LIB_H_ */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette