Luna/libc/src/arch/x86_64/crt0.S

39 lines
510 B
ArmAsm

.section .text
.global _start
.extern exit
.extern libc_init
.extern _init
.extern _fini
_start:
# Set up end of the stack frame linked list.
movq $0, %rbp
pushq %rbp # rip=0
pushq %rbp # rbp=0
movq %rsp, %rbp
pushq %rsi
pushq %rdi
pushq %rcx
call libc_init
# Run the global constructors.
call _init
popq %rdx
popq %rdi
popq %rsi
# Run main
call main
# Store the exit code before calling _fini.
push %rax
call _fini
# Terminate the process with the exit code.
pop %rdi
call exit