The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
elf_loader.h
Go to the documentation of this file.
1#pragma once
2
3#include "common/stdint.h"
4#include "arch/arch.h"
5#include "kernel/memory/vma.h"
6
7// result of a failed ELF load.
8#define ELF_LOAD_FAILED 0
9
10/**
11 * result of a successful ELF load.
12 */
13typedef struct
14{
15 uintptr_t entry; /* entry point virtual address */
16 uintptr_t brk; /* end of loaded segments (page-aligned, for sbrk) */
18
19/**
20 * load an ELF executable from the filesystem into user memory.
21 *
22 * opens the file at path, validates the ELF header, iterates PT_LOAD
23 * program headers, allocates physical pages, maps them as user-accessible
24 * into the specified page directory, and copies segment data.
25 * BSS regions (p_memsz > p_filesz) are zeroed.
26 *
27 * @param path absolute path to the ELF file on the filesystem.
28 * @param as the address space to map into.
29 * @param vmas receives one area per loaded segment (overlapping segments
30 * fail the load).
31 * @param result filled with entry point and program break on success.
32 * @return true on success, false on failure (invalid ELF, I/O error, OOM).
33 */
34bool elf_load(const char *path, addr_space_t as, vma_table_t *vmas, elf_load_result_t *result);
uintptr_t addr_space_t
an address space handle.
Definition arch.h:105
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.
Definition elf_loader.c:137
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:19
result of a successful ELF load.
Definition elf_loader.h:14
uintptr_t entry
Definition elf_loader.h:15
uintptr_t brk
Definition elf_loader.h:16
a process's areas, sorted by start.
Definition vma.h:58