The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
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
*/
13
typedef
struct
14
{
15
uintptr_t
entry
;
/* entry point virtual address */
16
uintptr_t
brk
;
/* end of loaded segments (page-aligned, for sbrk) */
17
}
elf_load_result_t
;
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
*/
34
bool
elf_load
(
const
char
*path,
addr_space_t
as,
vma_table_t
*vmas,
elf_load_result_t
*result);
arch.h
addr_space_t
uintptr_t addr_space_t
an address space handle.
Definition
arch.h:105
stdint.h
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.
Definition
elf_loader.c:137
uintptr_t
__UINTPTR_TYPE__ uintptr_t
Definition
stdint.h:19
elf_load_result_t
result of a successful ELF load.
Definition
elf_loader.h:14
elf_load_result_t::entry
uintptr_t entry
Definition
elf_loader.h:15
elf_load_result_t::brk
uintptr_t brk
Definition
elf_loader.h:16
vma_table_t
a process's areas, sorted by start.
Definition
vma.h:58
vma.h
src
kernel
elf
elf_loader.h
Generated by
1.18.0