Kernel/LibC/DynamicLoader: Update process start ABI

We now use SysV abi for process startup
This commit is contained in:
2025-04-15 23:04:20 +03:00
parent e6026cb0b8
commit 36baf7b0af
12 changed files with 314 additions and 280 deletions

View File

@@ -2,21 +2,22 @@
.global _start
_start:
pushq $0
# get argc, argv, envp
movq (%rsp), %rdi
leaq 8(%rsp), %rsi
leaq 8(%rsi, %rdi, 8), %rdx
# align stack
andq $-16, %rsp
xorq %rbp, %rbp
# save argc, argv, envp
subq $8, %rsp
pushq %rdi
pushq %rsi
pushq %rdx
# STACK LAYOUT
# null
# argc
# argv
# envp
xorq %rbp, %rbp
# init libc
movq 0(%rsp), %rdi
movq %rdx, %rdi # environ
pushq $__fini_array_end
pushq $__fini_array_start
@@ -31,9 +32,10 @@ _start:
addq $(6 * 8), %rsp
# call main
movq 16(%rsp), %rdi
movq 8(%rsp), %rsi
movq 0(%rsp), %rdx
popq %rdx
popq %rsi
popq %rdi
addq $8, %rsp
call main
# call exit