Kernel/LibC: pass environ pointer to process

This commit is contained in:
Bananymous
2023-06-05 20:34:08 +03:00
parent 6b73f4d187
commit 896b919c9d
6 changed files with 14 additions and 5 deletions

View File

@@ -25,7 +25,7 @@ continue_thread:
movq $0, %rax
jmp *%rsi
# void thread_userspace_trampoline(uint64_t rsp, uint64_t rip, int argc, char** argv)
# void thread_userspace_trampoline(uint64_t rsp, uint64_t rip, int argc, char** argv, char** envp)
.global thread_userspace_trampoline
thread_userspace_trampoline:
pushq $0x23
@@ -35,4 +35,5 @@ thread_userspace_trampoline:
pushq %rsi
movq %rdx, %rdi
movq %rcx, %rsi
movq %r8, %rdx
iretq

View File

@@ -9,10 +9,12 @@ _start:
movq %rsp, %rbp
# We need those in a moment when we call main.
pushq %rdx
pushq %rsi
pushq %rdi
# Prepare signals, memory allocation, stdio and such.
movq %rdx, %rdi
call _init_libc
# Run the global constructors.
@@ -21,6 +23,7 @@ _start:
# Restore argc and argv.
popq %rdi
popq %rsi
popq %rdx
# Run main
call main