2023-04-07 02:27:15 +03:00
|
|
|
.section .text
|
|
|
|
|
|
|
|
.global _start
|
|
|
|
_start:
|
2024-04-03 00:42:39 +03:00
|
|
|
pushq $0
|
|
|
|
pushq %rdi
|
|
|
|
pushq %rsi
|
|
|
|
pushq %rdx
|
|
|
|
|
2024-03-29 18:02:12 +02:00
|
|
|
# STACK LAYOUT
|
|
|
|
# null
|
|
|
|
# argc
|
|
|
|
# argv
|
|
|
|
# envp
|
2023-04-07 02:27:15 +03:00
|
|
|
|
2024-03-29 18:02:12 +02:00
|
|
|
xorq %rbp, %rbp
|
2023-04-07 02:27:15 +03:00
|
|
|
|
2024-03-29 18:02:12 +02:00
|
|
|
# init libc
|
|
|
|
movq 0(%rsp), %rdi
|
2023-05-29 20:21:19 +03:00
|
|
|
call _init_libc
|
2023-04-07 02:27:15 +03:00
|
|
|
|
2024-03-29 18:02:12 +02:00
|
|
|
# call global constructors
|
2023-04-07 02:27:15 +03:00
|
|
|
call _init
|
|
|
|
|
2024-08-26 14:04:58 +03:00
|
|
|
movq $__init_array_start, %rbx
|
|
|
|
jmp 2f
|
2024-09-05 12:59:05 +03:00
|
|
|
1: call *(%rbx)
|
2024-08-26 14:04:58 +03:00
|
|
|
addq $8, %rbx
|
|
|
|
2: cmpq $__init_array_end, %rbx
|
|
|
|
jne 1b
|
|
|
|
|
2024-03-29 18:02:12 +02:00
|
|
|
# call main
|
|
|
|
movq 16(%rsp), %rdi
|
|
|
|
movq 8(%rsp), %rsi
|
|
|
|
movq 0(%rsp), %rdx
|
2023-04-07 02:27:15 +03:00
|
|
|
call main
|
|
|
|
|
2024-03-29 18:02:12 +02:00
|
|
|
# call exit
|
|
|
|
movq %rax, %rdi
|
2023-04-07 02:27:15 +03:00
|
|
|
call exit
|
2023-10-30 11:06:13 +02:00
|
|
|
|
2023-04-07 02:27:15 +03:00
|
|
|
.size _start, . - _start
|