The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
elf_loader.c File Reference
#include "elf_loader.h"
#include "elf.h"
#include "kernel/vfs/vfs.h"
#include "kernel/memory/pmm.h"
#include "kernel/memory/heap.h"
#include "arch/arch.h"
#include "common/memory.h"
#include "kernel/memory/page.h"
#include "kernel/memory/mman.h"

Functions

bool elf_load (const char *path, addr_space_t as, vma_table_t *vmas, elf_load_result_t *result)
 load an ELF executable from the filesystem into user memory.

Function Documentation

◆ elf_load()

bool elf_load ( const char * path,
addr_space_t as,
vma_table_t * vmas,
elf_load_result_t * result )

load an ELF executable from the filesystem into user memory.

opens the file at path, validates the ELF header, iterates PT_LOAD program headers, allocates physical pages, maps them as user-accessible into the specified page directory, and copies segment data. BSS regions (p_memsz > p_filesz) are zeroed.

Parameters
pathabsolute path to the ELF file on the filesystem.
asthe address space to map into.
vmasreceives one area per loaded segment (overlapping segments fail the load).
resultfilled with entry point and program break on success.
Returns
true on success, false on failure (invalid ELF, I/O error, OOM).