Loading...
Searching...
No Matches
elf_file.h
Go to the documentation of this file.
1
5#pragma once
6#include <storage/storage.h>
8#include "elf_api_interface.h"
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14typedef struct ELFFile ELFFile;
15
16typedef struct {
17 const char* name;
18 uint32_t address;
20
21typedef struct {
22 uint32_t debug_link_size;
23 uint8_t* debug_link;
25
26typedef struct {
27 uint32_t mmap_entry_count;
28 ELFMemoryMapEntry* mmap_entries;
29 ELFDebugLinkInfo debug_link_info;
30 off_t entry;
32
33typedef enum {
34 ELFFileLoadStatusSuccess = 0,
35 ELFFileLoadStatusUnspecifiedError,
36 ELFFileLoadStatusMissingImports,
37} ELFFileLoadStatus;
38
39typedef enum {
40 ElfProcessSectionResultNotFound,
41 ElfProcessSectionResultCannotProcess,
42 ElfProcessSectionResultSuccess,
43} ElfProcessSectionResult;
44
45typedef enum {
46 ElfLoadSectionTableResultError,
47 ElfLoadSectionTableResultNoMemory,
48 ElfLoadSectionTableResultSuccess,
49} ElfLoadSectionTableResult;
50
51typedef bool(ElfProcessSection)(File* file, size_t offset, size_t size, void* context);
52
59ELFFile* elf_file_alloc(Storage* storage, const ElfApiInterface* api_interface);
60
65void elf_file_free(ELFFile* elf_file);
66
73bool elf_file_open(ELFFile* elf_file, const char* path);
74
80ElfLoadSectionTableResult elf_file_load_section_table(ELFFile* elf_file);
81
87ELFFileLoadStatus elf_file_load_sections(ELFFile* elf_file);
88
96
102
108void* elf_file_get_entry_point(ELFFile* elf_file);
109
116void elf_file_call_fini(ELFFile* elf);
117
124
130void elf_file_init_debug_info(ELFFile* elf_file, ELFDebugInfo* debug_info);
131
137
147ElfProcessSectionResult elf_process_section(
148 ELFFile* elf_file,
149 const char* name,
150 ElfProcessSection* process_section,
151 void* context);
152
153#ifdef __cplusplus
154}
155#endif
Flipper application manifest.
ElfLoadSectionTableResult elf_file_load_section_table(ELFFile *elf_file)
Load ELF file section table (load stage #1)
Definition elf_file.c:885
bool elf_file_is_init_complete(ELFFile *elf)
Check if ELF file pre-run stage was executed and its code is runnable.
Definition elf_file.c:1026
void elf_file_call_fini(ELFFile *elf)
Execute ELF file post-run stage, call static destructors for example (load stage #5) Must be done if ...
Definition elf_file.c:1035
const ElfApiInterface * elf_file_get_api_interface(ELFFile *elf_file)
Get ELF file API interface.
Definition elf_file.c:1041
void elf_file_call_init(ELFFile *elf)
Execute ELF file pre-run stage, call static constructors for example (load stage #3) Must be done bef...
Definition elf_file.c:1019
ELFFile * elf_file_alloc(Storage *storage, const ElfApiInterface *api_interface)
Allocate ELFFile instance.
Definition elf_file.c:810
void elf_file_init_debug_info(ELFFile *elf_file, ELFDebugInfo *debug_info)
Get ELF file debug info.
Definition elf_file.c:1045
ELFFileLoadStatus elf_file_load_sections(ELFFile *elf_file)
Load and relocate ELF file sections (load stage #2)
Definition elf_file.c:973
ElfProcessSectionResult elf_process_section(ELFFile *elf_file, const char *name, ElfProcessSection *process_section, void *context)
Process ELF file section.
Definition elf_file.c:938
bool elf_file_open(ELFFile *elf_file, const char *path)
Open ELF file.
Definition elf_file.c:866
void elf_file_free(ELFFile *elf_file)
Free ELFFile instance.
Definition elf_file.c:820
void elf_file_clear_debug_info(ELFDebugInfo *debug_info)
Clear ELF file debug info generated by elf_file_init_debug_info.
Definition elf_file.c:1071
void * elf_file_get_entry_point(ELFFile *elf_file)
Get actual entry point for ELF file.
Definition elf_file.c:1030
APIs for working with storages, directories and files.
Definition elf_file.h:26
Definition elf_file_i.h:31
Definition elf_file.h:16
Interface for ELF loader to resolve symbols.
Definition elf_api_interface.h:9
Structure that hold file index and returned api errors.
Definition filesystem_api_internal.h:17
Definition storage_i.h:23