2022-09-25 17:11:29 +03:00
|
|
|
#pragma once
|
|
|
|
#include "elf_file.h"
|
|
|
|
#include <m-dict.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2023-10-12 19:34:30 +03:00
|
|
|
DICT_DEF2(AddressCache, int, M_DEFAULT_OPLIST, Elf32_Addr, M_DEFAULT_OPLIST) //-V1048
|
2022-09-25 17:11:29 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Callable elf entry type
|
|
|
|
*/
|
|
|
|
typedef int32_t(entry_t)(void*);
|
|
|
|
|
2023-06-28 11:19:10 +03:00
|
|
|
typedef struct ELFSection ELFSection;
|
|
|
|
|
|
|
|
struct ELFSection {
|
2022-09-25 17:11:29 +03:00
|
|
|
void* data;
|
|
|
|
Elf32_Word size;
|
2022-10-07 20:06:29 +03:00
|
|
|
|
|
|
|
size_t rel_count;
|
|
|
|
Elf32_Off rel_offset;
|
2023-06-28 11:19:10 +03:00
|
|
|
ELFSection* fast_rel;
|
|
|
|
|
|
|
|
uint16_t sec_idx;
|
|
|
|
};
|
2022-09-25 17:11:29 +03:00
|
|
|
|
|
|
|
DICT_DEF2(ELFSectionDict, const char*, M_CSTR_OPLIST, ELFSection, M_POD_OPLIST)
|
|
|
|
|
|
|
|
struct ELFFile {
|
|
|
|
size_t sections_count;
|
|
|
|
off_t section_table;
|
|
|
|
off_t section_table_strings;
|
|
|
|
|
|
|
|
size_t symbol_count;
|
|
|
|
off_t symbol_table;
|
|
|
|
off_t symbol_table_strings;
|
|
|
|
off_t entry;
|
|
|
|
ELFSectionDict_t sections;
|
|
|
|
|
|
|
|
AddressCache_t relocation_cache;
|
|
|
|
AddressCache_t trampoline_cache;
|
|
|
|
|
|
|
|
File* fd;
|
|
|
|
const ElfApiInterface* api_interface;
|
|
|
|
ELFDebugLinkInfo debug_link_info;
|
2022-10-07 20:06:29 +03:00
|
|
|
|
|
|
|
ELFSection* preinit_array;
|
|
|
|
ELFSection* init_array;
|
|
|
|
ELFSection* fini_array;
|
2023-03-14 17:29:28 +03:00
|
|
|
|
|
|
|
bool init_array_called;
|
2022-09-25 17:11:29 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|