Fix: program returned random values because _exit wasn't called correctly

This commit is contained in:
g1n 2021-12-16 20:34:06 +02:00
parent 258b647cb7
commit 42c5e12a58
1 changed files with 4 additions and 8 deletions

View File

@ -1,8 +1,9 @@
#include <liblinux/syscall.h>
#include <liblinux/start.h>
void _exit() {
syscall(__NR_exit);
void _exit(int status) {
__asm("mov %eax, %edi\n");
syscall(__NR_exit, status);
}
void _start() {
@ -10,11 +11,6 @@ void _start() {
"mov (%rsp), %edi\n"
"lea 8(%rsp), %rsi\n"
"lea 16(%rsp,%rdi,8), %rdx\n"
"xor %eax, %eax\n"
"call main\n"
"mov %eax, %edi\n"
"xor %eax, %eax\n");
_exit();
_exit(main());
}