1 | /** @file
|
---|
2 | ELF library
|
---|
3 |
|
---|
4 | Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #ifndef EFI_LIB_INTERNAL_H_
|
---|
10 | #define EFI_LIB_INTERNAL_H_
|
---|
11 |
|
---|
12 | #include <Library/BaseLib.h>
|
---|
13 | #include <Library/DebugLib.h>
|
---|
14 | #include <Library/BaseMemoryLib.h>
|
---|
15 | #include "ElfLib.h"
|
---|
16 | #include "ElfCommon.h"
|
---|
17 | #include "Elf32.h"
|
---|
18 | #include "Elf64.h"
|
---|
19 |
|
---|
20 | #define ELF_NEXT_ENTRY(EntryType, Current, EntrySize) \
|
---|
21 | ((EntryType *) ((UINT8 *)Current + EntrySize))
|
---|
22 |
|
---|
23 | /**
|
---|
24 | Return the section header specified by Index.
|
---|
25 |
|
---|
26 | @param ImageBase The image base.
|
---|
27 | @param Index The section index.
|
---|
28 |
|
---|
29 | @return Pointer to the section header.
|
---|
30 | **/
|
---|
31 | Elf32_Shdr *
|
---|
32 | GetElf32SectionByIndex (
|
---|
33 | IN UINT8 *ImageBase,
|
---|
34 | IN UINT32 Index
|
---|
35 | );
|
---|
36 |
|
---|
37 | /**
|
---|
38 | Return the section header specified by Index.
|
---|
39 |
|
---|
40 | @param ImageBase The image base.
|
---|
41 | @param Index The section index.
|
---|
42 |
|
---|
43 | @return Pointer to the section header.
|
---|
44 | **/
|
---|
45 | Elf64_Shdr *
|
---|
46 | GetElf64SectionByIndex (
|
---|
47 | IN UINT8 *ImageBase,
|
---|
48 | IN UINT32 Index
|
---|
49 | );
|
---|
50 |
|
---|
51 | /**
|
---|
52 | Return the segment header specified by Index.
|
---|
53 |
|
---|
54 | @param ImageBase The image base.
|
---|
55 | @param Index The segment index.
|
---|
56 |
|
---|
57 | @return Pointer to the segment header.
|
---|
58 | **/
|
---|
59 | Elf32_Phdr *
|
---|
60 | GetElf32SegmentByIndex (
|
---|
61 | IN UINT8 *ImageBase,
|
---|
62 | IN UINT32 Index
|
---|
63 | );
|
---|
64 |
|
---|
65 | /**
|
---|
66 | Return the segment header specified by Index.
|
---|
67 |
|
---|
68 | @param ImageBase The image base.
|
---|
69 | @param Index The segment index.
|
---|
70 |
|
---|
71 | @return Pointer to the segment header.
|
---|
72 | **/
|
---|
73 | Elf64_Phdr *
|
---|
74 | GetElf64SegmentByIndex (
|
---|
75 | IN UINT8 *ImageBase,
|
---|
76 | IN UINT32 Index
|
---|
77 | );
|
---|
78 |
|
---|
79 | /**
|
---|
80 | Load ELF image which has 32-bit architecture
|
---|
81 |
|
---|
82 | @param[in] ElfCt ELF image context pointer.
|
---|
83 |
|
---|
84 | @retval EFI_SUCCESS ELF binary is loaded successfully.
|
---|
85 | @retval Others Loading ELF binary fails.
|
---|
86 |
|
---|
87 | **/
|
---|
88 | EFI_STATUS
|
---|
89 | LoadElf32Image (
|
---|
90 | IN ELF_IMAGE_CONTEXT *ElfCt
|
---|
91 | );
|
---|
92 |
|
---|
93 | /**
|
---|
94 | Load ELF image which has 64-bit architecture
|
---|
95 |
|
---|
96 | @param[in] ImageBase Memory address of an image.
|
---|
97 | @param[out] EntryPoint The entry point of loaded ELF image.
|
---|
98 |
|
---|
99 | @retval EFI_SUCCESS ELF binary is loaded successfully.
|
---|
100 | @retval Others Loading ELF binary fails.
|
---|
101 |
|
---|
102 | **/
|
---|
103 | EFI_STATUS
|
---|
104 | LoadElf64Image (
|
---|
105 | IN ELF_IMAGE_CONTEXT *ElfCt
|
---|
106 | );
|
---|
107 |
|
---|
108 | #endif
|
---|