|
PatchworkOS
19e446b
A non-POSIX operating system.
|
Program loading and user stack management. More...
Program loading and user stack management.
The loader is responsible for loading programs into memory, setting up the initial user stack, and performing the jump to userspace.
When a new program is loaded, we pass the command line arguments (argv) to the program via the user stack and registers.
The stack is set up as follows:
| Stack Contents |
|---|
| *argv[argc - 1] |
| ... |
| *argv[0] |
| NULL |
| argv[argc - 1] |
| ... |
| argv[0] |
| padding |
The argv pointer is placed in the rsi register, and the argc value is placed in the rdi register.
Note that rsp points to argc when the program starts executing.
Functions | |
| _NORETURN void | loader_exec (void) |
| Causes the currently running thread to load and execute a new program. | |
| _NORETURN void loader_exec | ( | void | ) |
Causes the currently running thread to load and execute a new program.
Intended to be used as the entry point for a newly created process, causing it to run the executable specified in its command line arguments.
Definition at line 40 of file loader.c.