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 39c1956819
commit a9c0fcdfde
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() { void _start() {
_init(); _init();
unsigned long long zero = 0;
__asm__ __volatile__("movq %%rbp, %[input]" : : [input] "m" (zero) : );
int ex = Main(); int ex = Main();
Exit(ex); Exit(ex);
} }

Binary file not shown.

BIN
global/crt0.old Normal file

Binary file not shown.

View File

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