LF OS
Hobby operating system for amd64 with high ambitions
|
Go to the source code of this file.
Data Structures | |
struct | Symbol |
struct | SymbolData |
Functions | |
ptr_t | load_elf (ptr_t start, struct vm_table *context, ptr_t *data_start, ptr_t *data_end) |
elf_section_header_t * | elf_section_by_name (const char *name, const void *elf) |
void * | elf_load_symbols (ptr_t elf, allocator_t *alloc) |
bool | elf_symbolize (void *symbol_data, ptr_t addr, size_t *symbol_size, char *symbol) |
struct Symbol |
struct SymbolData |
Data Fields | ||
---|---|---|
allocator_t * | alloc | |
uint64_t | numSymbols | |
char * | symbolNames | |
struct Symbol | symbols[0] |
void * elf_load_symbols | ( | ptr_t | elf, |
allocator_t * | alloc | ||
) |
Load symbols of the provided ELF file.
elf | ELF file already loaded into memory |
alloc | Allocator to use for dynamically allocating memory |
Definition at line 101 of file elf.c.
References elf_symbol::addr, Symbol::address, allocator::alloc, alloc, elf_section_by_name(), elf_section_header::entrySize, header, logw, memcpy(), Symbol::name, elf_symbol::name, SymbolData::numSymbols, elf_section_header::offset, and elf_section_header::size.
elf_section_header_t * elf_section_by_name | ( | const char * | name, |
const void * | elf | ||
) |
Return section header of ELF file by name
name | Name of the section to return |
elf | Loaded ELF image in memory |
Definition at line 71 of file elf.c.
References name, elf_section_header::name, elf_section_header::offset, elf_file_header::sectionHeaderCount, elf_file_header::sectionHeaderEntrySize, elf_file_header::sectionHeaderOffset, elf_file_header::sectionHeaderSectionNameIndex, and strcmp().
Get the symbol name (and offset) for a given address from the data loaded with elf_load_symbols.
symbols | Opaque data structure returned by elf_load_symbols |
addr | Address to symbolize |
symbol_length | Input for size of the buffer where to write symbol, output actual size of either the data written into the buffer or the size needed for the buffer |
symbol | Output buffer where to write the symbol |
Definition at line 133 of file elf.c.
References addr, Symbol::address, ksnprintf(), Symbol::name, SymbolData::numSymbols, strlen(), strncpy(), SymbolData::symbolNames, and SymbolData::symbols.
Parse ELF file, map program segments to context and return proper location for stack.
[in] | elf | Memory chunk where the ELF file is loaded. |
[in] | context | VM context for mapping of program segments. |
[out] | data_start | Start of the data section |
[out] | data_end | End of the data section |
Definition at line 7 of file elf.c.
References ALLOCATOR_REGION_DIRECT_MAPPING, data_end, ELF_MAGIC, fileLength, elf_program_header::fileLength, header, logf, memcpy(), elf_program_header::memLength, memset(), mm_alloc_pages(), offset, elf_program_header::offset, elf_program_header::type, elf_program_header::vaddr, and vm_context_map().