|
PatchworkOS
da8a090
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:
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 (const char *executable, char **argv, uint64_t argc) |
| Causes the currently running thread to load and execute a new program. | |
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 specified executable with the given arguments and environment variables.
executable and argv along with their contents will be freed by this function, they must be heap allocated and not used after calling this function.| executable | The path to the executable file, will be freed by the loader. |
| argv | The argument vector for the new program, will be freed by the loader along with its contents, can be NULL if argc is 0. |
| argc | The number of arguments in argv. |
Definition at line 39 of file loader.c.