Loading...
Searching...
No Matches
elf_file.h File Reference

ELF file loader. More...

#include <storage/storage.h>
#include "../application_manifest.h"
#include "elf_api_interface.h"

Go to the source code of this file.

Data Structures

struct  ELFMemoryMapEntry
 
struct  ELFDebugLinkInfo
 
struct  ELFDebugInfo
 

Typedefs

typedef struct ELFFile ELFFile
 
typedef bool ElfProcessSection(File *file, size_t offset, size_t size, void *context)
 

Enumerations

enum  ELFFileLoadStatus { ELFFileLoadStatusSuccess = 0 , ELFFileLoadStatusUnspecifiedError , ELFFileLoadStatusMissingImports }
 
enum  ElfProcessSectionResult { ElfProcessSectionResultNotFound , ElfProcessSectionResultCannotProcess , ElfProcessSectionResultSuccess }
 
enum  ElfLoadSectionTableResult { ElfLoadSectionTableResultError , ElfLoadSectionTableResultNoMemory , ElfLoadSectionTableResultSuccess }
 

Functions

ELFFileelf_file_alloc (Storage *storage, const ElfApiInterface *api_interface)
 Allocate ELFFile instance.
 
void elf_file_free (ELFFile *elf_file)
 Free ELFFile instance.
 
bool elf_file_open (ELFFile *elf_file, const char *path)
 Open ELF file.
 
ElfLoadSectionTableResult elf_file_load_section_table (ELFFile *elf_file)
 Load ELF file section table (load stage #1)
 
ELFFileLoadStatus elf_file_load_sections (ELFFile *elf_file)
 Load and relocate ELF file sections (load stage #2)
 
void elf_file_call_init (ELFFile *elf)
 Execute ELF file pre-run stage, call static constructors for example (load stage #3) Must be done before invoking any code from the ELF file.
 
bool elf_file_is_init_complete (ELFFile *elf)
 Check if ELF file pre-run stage was executed and its code is runnable.
 
void * elf_file_get_entry_point (ELFFile *elf_file)
 Get actual entry point for ELF file.
 
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 any code from the ELF file was executed.
 
const ElfApiInterfaceelf_file_get_api_interface (ELFFile *elf_file)
 Get ELF file API interface.
 
void elf_file_init_debug_info (ELFFile *elf_file, ELFDebugInfo *debug_info)
 Get ELF file debug info.
 
void elf_file_clear_debug_info (ELFDebugInfo *debug_info)
 Clear ELF file debug info generated by elf_file_init_debug_info.
 
ElfProcessSectionResult elf_process_section (ELFFile *elf_file, const char *name, ElfProcessSection *process_section, void *context)
 Process ELF file section.
 

Detailed Description

ELF file loader.

Function Documentation

◆ elf_file_alloc()

ELFFile * elf_file_alloc ( Storage * storage,
const ElfApiInterface * api_interface )

Allocate ELFFile instance.

Parameters
storage
api_interface
Returns
ELFFile*

◆ elf_file_call_fini()

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 any code from the ELF file was executed.

Parameters
elf

◆ elf_file_call_init()

void elf_file_call_init ( ELFFile * elf)

Execute ELF file pre-run stage, call static constructors for example (load stage #3) Must be done before invoking any code from the ELF file.

Parameters
elf

◆ elf_file_clear_debug_info()

void elf_file_clear_debug_info ( ELFDebugInfo * debug_info)

Clear ELF file debug info generated by elf_file_init_debug_info.

Parameters
debug_info

◆ elf_file_free()

void elf_file_free ( ELFFile * elf_file)

Free ELFFile instance.

Parameters
elf_file

◆ elf_file_get_api_interface()

const ElfApiInterface * elf_file_get_api_interface ( ELFFile * elf_file)

Get ELF file API interface.

Parameters
elf_file
Returns
const ElfApiInterface*

◆ elf_file_get_entry_point()

void * elf_file_get_entry_point ( ELFFile * elf_file)

Get actual entry point for ELF file.

Parameters
elf_file
Returns
void*

◆ elf_file_init_debug_info()

void elf_file_init_debug_info ( ELFFile * elf_file,
ELFDebugInfo * debug_info )

Get ELF file debug info.

Parameters
elf_file
debug_info

◆ elf_file_is_init_complete()

bool elf_file_is_init_complete ( ELFFile * elf)

Check if ELF file pre-run stage was executed and its code is runnable.

Parameters
elf

◆ elf_file_load_section_table()

ElfLoadSectionTableResult elf_file_load_section_table ( ELFFile * elf_file)

Load ELF file section table (load stage #1)

Parameters
elf_file
Returns
ElfLoadSectionTableResult

◆ elf_file_load_sections()

ELFFileLoadStatus elf_file_load_sections ( ELFFile * elf_file)

Load and relocate ELF file sections (load stage #2)

Parameters
elf_file
Returns
ELFFileLoadStatus

◆ elf_file_open()

bool elf_file_open ( ELFFile * elf_file,
const char * path )

Open ELF file.

Parameters
elf_file
path
Returns
bool

◆ elf_process_section()

ElfProcessSectionResult elf_process_section ( ELFFile * elf_file,
const char * name,
ElfProcessSection * process_section,
void * context )

Process ELF file section.

Parameters
elf_file
name
process_section
context
Returns
ElfProcessSectionResult