2023-01-06 13:31:14 +01:00
|
|
|
.section .text
|
|
|
|
|
|
|
|
.global _start
|
|
|
|
.extern exit
|
2023-03-18 19:23:18 +01:00
|
|
|
.extern libc_init
|
2023-01-06 13:31:14 +01:00
|
|
|
_start:
|
|
|
|
# Set up end of the stack frame linked list.
|
|
|
|
movq $0, %rbp
|
|
|
|
pushq %rbp # rip=0
|
|
|
|
pushq %rbp # rbp=0
|
|
|
|
movq %rsp, %rbp
|
|
|
|
|
2023-03-18 22:25:19 +01:00
|
|
|
pushq %rsi
|
|
|
|
pushq %rdi
|
2023-04-07 15:03:38 +02:00
|
|
|
pushq %rcx
|
2023-03-18 22:25:19 +01:00
|
|
|
|
2023-03-18 19:23:18 +01:00
|
|
|
call libc_init
|
|
|
|
|
2023-01-06 13:31:14 +01:00
|
|
|
# Run the global constructors.
|
|
|
|
call _init
|
|
|
|
|
2023-04-07 15:03:38 +02:00
|
|
|
popq %rdx
|
2023-03-18 22:25:19 +01:00
|
|
|
popq %rdi
|
|
|
|
popq %rsi
|
|
|
|
|
2023-01-06 13:31:14 +01:00
|
|
|
# Run main
|
|
|
|
call main
|
|
|
|
|
|
|
|
# Terminate the process with the exit code.
|
|
|
|
movl %eax, %edi
|
|
|
|
call exit
|