2024-03-21 15:20:20 +02:00
|
|
|
.section .text
|
|
|
|
|
|
|
|
.global _start
|
|
|
|
_start:
|
|
|
|
pushl $0
|
2024-04-03 02:23:23 +03:00
|
|
|
pushl %edi
|
|
|
|
pushl %esi
|
|
|
|
pushl %edx
|
2024-03-21 15:20:20 +02:00
|
|
|
|
2024-04-03 02:23:23 +03:00
|
|
|
# STACK LAYOUT
|
|
|
|
# null
|
|
|
|
# argc
|
|
|
|
# argv
|
|
|
|
# envp
|
2024-03-21 15:20:20 +02:00
|
|
|
|
2024-04-03 02:23:23 +03:00
|
|
|
xorl %ebp, %ebp
|
2024-03-21 15:20:20 +02:00
|
|
|
|
2024-04-03 02:23:23 +03:00
|
|
|
# init libc (envp already as argument)
|
2024-03-21 15:20:20 +02:00
|
|
|
call _init_libc
|
|
|
|
|
2024-04-03 02:23:23 +03:00
|
|
|
# call global constructors
|
2024-03-21 15:20:20 +02:00
|
|
|
call _init
|
|
|
|
|
2024-04-03 02:23:23 +03:00
|
|
|
# call main
|
|
|
|
movl 0(%esp), %eax
|
|
|
|
xchgl %eax, 8(%esp)
|
|
|
|
movl %eax, (%esp)
|
2024-03-21 15:20:20 +02:00
|
|
|
call main
|
|
|
|
|
2024-04-03 02:23:23 +03:00
|
|
|
subl $12, %esp
|
2024-03-21 15:20:20 +02:00
|
|
|
pushl %eax
|
|
|
|
call exit
|
|
|
|
|
|
|
|
.size _start, . - _start
|