mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-27 23:10:22 +00:00
e6d22ed147
* fap-loader: load all code and data sections * fap-loader: relocate all code and data sections * fap-loader: remove old elf loader * fap-loader: new jmp call relocation * openocd: resume on detach * fap-loader: trampoline for big jumps * fap-loader: rename cache * fap-loader: init_array support * fap-loader: untangled flipper_application into separate entities * fap-loader: fix debug * fap-loader: optimize section container * fap-loader: optimize key for section container * fap-loader: disable debug log * documentation * F7: bump api symbols version * Lib: cleanup elf_file.c Co-authored-by: あく <alleteam@gmail.com>
127 lines
No EOL
2.7 KiB
C
127 lines
No EOL
2.7 KiB
C
/**
|
|
* @file elf_file.h
|
|
* ELF file loader
|
|
*/
|
|
#pragma once
|
|
#include <storage/storage.h>
|
|
#include "../application_manifest.h"
|
|
#include "elf_api_interface.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct ELFFile ELFFile;
|
|
|
|
typedef struct {
|
|
const char* name;
|
|
uint32_t address;
|
|
} ELFMemoryMapEntry;
|
|
|
|
typedef struct {
|
|
uint32_t debug_link_size;
|
|
uint8_t* debug_link;
|
|
} ELFDebugLinkInfo;
|
|
|
|
typedef struct {
|
|
uint32_t mmap_entry_count;
|
|
ELFMemoryMapEntry* mmap_entries;
|
|
ELFDebugLinkInfo debug_link_info;
|
|
off_t entry;
|
|
} ELFDebugInfo;
|
|
|
|
typedef enum {
|
|
ELFFileLoadStatusSuccess = 0,
|
|
ELFFileLoadStatusUnspecifiedError,
|
|
ELFFileLoadStatusNoFreeMemory,
|
|
ELFFileLoadStatusMissingImports,
|
|
} ELFFileLoadStatus;
|
|
|
|
/**
|
|
* @brief Allocate ELFFile instance
|
|
* @param storage
|
|
* @param api_interface
|
|
* @return ELFFile*
|
|
*/
|
|
ELFFile* elf_file_alloc(Storage* storage, const ElfApiInterface* api_interface);
|
|
|
|
/**
|
|
* @brief Free ELFFile instance
|
|
* @param elf_file
|
|
*/
|
|
void elf_file_free(ELFFile* elf_file);
|
|
|
|
/**
|
|
* @brief Open ELF file
|
|
* @param elf_file
|
|
* @param path
|
|
* @return bool
|
|
*/
|
|
bool elf_file_open(ELFFile* elf_file, const char* path);
|
|
|
|
/**
|
|
* @brief Load ELF file manifest
|
|
* @param elf
|
|
* @param manifest
|
|
* @return bool
|
|
*/
|
|
bool elf_file_load_manifest(ELFFile* elf, FlipperApplicationManifest* manifest);
|
|
|
|
/**
|
|
* @brief Load ELF file section table (load stage #1)
|
|
* @param elf_file
|
|
* @param manifest
|
|
* @return bool
|
|
*/
|
|
bool elf_file_load_section_table(ELFFile* elf_file, FlipperApplicationManifest* manifest);
|
|
|
|
/**
|
|
* @brief Load and relocate ELF file sections (load stage #2)
|
|
* @param elf_file
|
|
* @return ELFFileLoadStatus
|
|
*/
|
|
ELFFileLoadStatus elf_file_load_sections(ELFFile* elf_file);
|
|
|
|
/**
|
|
* @brief Execute ELF file pre-run stage, call static constructors for example (load stage #3)
|
|
* @param elf
|
|
*/
|
|
void elf_file_pre_run(ELFFile* elf);
|
|
|
|
/**
|
|
* @brief Run ELF file (load stage #4)
|
|
* @param elf_file
|
|
* @param args
|
|
* @return int32_t
|
|
*/
|
|
int32_t elf_file_run(ELFFile* elf_file, void* args);
|
|
|
|
/**
|
|
* @brief Execute ELF file post-run stage, call static destructors for example (load stage #5)
|
|
* @param elf
|
|
*/
|
|
void elf_file_post_run(ELFFile* elf);
|
|
|
|
/**
|
|
* @brief Get ELF file API interface
|
|
* @param elf_file
|
|
* @return const ElfApiInterface*
|
|
*/
|
|
const ElfApiInterface* elf_file_get_api_interface(ELFFile* elf_file);
|
|
|
|
/**
|
|
* @brief Get ELF file debug info
|
|
* @param elf_file
|
|
* @param debug_info
|
|
*/
|
|
void elf_file_init_debug_info(ELFFile* elf_file, ELFDebugInfo* debug_info);
|
|
|
|
/**
|
|
* @brief Clear ELF file debug info generated by elf_file_init_debug_info
|
|
* @param debug_info
|
|
*/
|
|
void elf_file_clear_debug_info(ELFDebugInfo* debug_info);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif |