Adjust the crt0 file to insert a null stack frame before calling the kernel. Provides a solid base for the stack unwinding.

This commit is contained in:
Curle 2020-11-09 18:44:42 +00:00
parent 9b0aceac55
commit bd8213356e
Signed by: TheCurle
GPG Key ID: 5942F13718443F79
4 changed files with 18 additions and 4 deletions

View File

@ -6,6 +6,8 @@ extern void _init();
void _start() {
_init();
unsigned long long zero = 0;
__asm__ __volatile__("movq %%rbp, %[input]" : : [input] "m" (zero) : );
int ex = Main();
Exit(ex);
}

Binary file not shown.

BIN
global/crt0.old Normal file

Binary file not shown.

View File

@ -1,10 +1,22 @@
.section .text
.global _start
.global _init
.global main
.global _fini
.global Main
.global Exit
.type _start, @function
_start:
push %rbp
movq %rsp, %rbp
sub $0x10, %rsp
xor %rax, %rax
call _init
call main
call _fini
xor %rbp, %rbp
xor %rax, %rax
call Main
movq %rax, %rdi
call Exit