|
ginnOS
The reference: libc, the libraries and the kernel
|
#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. | |
| 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.
| path | absolute path to the ELF file on the filesystem. |
| as | the address space to map into. |
| vmas | receives one area per loaded segment (overlapping segments fail the load). |
| result | filled with entry point and program break on success. |