Some little fixes (now gcc compiles empty file without errors)

This commit is contained in:
g1n 2021-08-02 20:48:07 +03:00
parent 8e5823ad96
commit 1766a07e16
2 changed files with 20 additions and 3 deletions

View File

@ -13,7 +13,7 @@ _start:
pushq %rdi pushq %rdi
# Prepare signals, memory allocation, stdio and such. # Prepare signals, memory allocation, stdio and such.
call initialize_standard_library # call initialize_standard_library
# Run the global constructors. # Run the global constructors.
call _init call _init
@ -23,9 +23,24 @@ _start:
popq %rsi popq %rsi
# Run main # Run main
call main # call main
# Terminate the process with the exit code. # Terminate the process with the exit code.
movl %eax, %edi movl %eax, %edi
call exit call exit
.size _start, . - _start
.global _init
_init:
push %rbp
movq %rsp, %rbp
.global _fini
_fini:
push %rbp
movq %rsp, %rbp
.global exit
exit:
call _fini
.size _start, . - _start

View File

@ -1,5 +1,6 @@
.section .init .section .init
.global _init .global _init
.type _init, @function
_init: _init:
push %rbp push %rbp
movq %rsp, %rbp movq %rsp, %rbp
@ -7,6 +8,7 @@ _init:
.section .fini .section .fini
.global _fini .global _fini
.type _fini, @function
_fini: _fini:
push %rbp push %rbp
movq %rsp, %rbp movq %rsp, %rbp