ElfFileOpen
Description
Open and parse an ELF file from disk.
Parameters
| Name | Direction | Description |
|---|---|---|
out |
out | Populated on success. |
path |
in | Filesystem path. |
alloc |
in | Allocator for the read-in byte buffer and the section / symbol vectors. Must outlive the ElfFile. |
Success
Returns true; out is fully populated and out->owns_data is true.
Failure
Returns false; logs the failing step (open / read / magic / class / decoding). out is left zeroed.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Dwarf.c:22:
ElfFile elf;
if (!ElfFileOpen(&elf, "/proc/self/exe", ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Dwarf.c:61:
ElfFile elf;
if (!ElfFileOpen(&elf, r.module_path, base)) {
SymbolResolverDeinit(&res);
DefaultAllocatorDeinit(&alloc);- In
Elf.c:14:
ElfFile elf;
bool opened = ElfFileOpen(&elf, "/proc/self/exe", ALLOCATOR_OF(&alloc));
if (!opened) {
DefaultAllocatorDeinit(&alloc);- In
Elf.c:37:
ElfFile elf;
if (!ElfFileOpen(&elf, "/proc/self/exe", ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:57:
ElfFile elf;
if (!ElfFileOpen(&elf, "/proc/self/exe", ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; entry.path = path;
entry.load_base = load_base;
if (!ElfFileOpen(&entry.elf, path, self->allocator)) {
return NULL;
}- In
Elf.c:340:
}
bool ElfFileOpen(ElfFile *out, const char *path, Allocator *alloc) {
if (!out || !path || !alloc) {
LOG_ERROR("ElfFileOpen: NULL argument");- In
Elf.c:342:
bool ElfFileOpen(ElfFile *out, const char *path, Allocator *alloc) {
if (!out || !path || !alloc) {
LOG_ERROR("ElfFileOpen: NULL argument");
return false;
}- In
Elf.c:349:
u64 capacity = 0;
if (!ReadCompleteFile(path, &buf, &bytes, &capacity, alloc)) {
LOG_ERROR("ElfFileOpen: failed to read {}", path);
return false;
}
Last updated on