summaryrefslogtreecommitdiff
path: root/src/crt/crt0.s
blob: 8c735f11999c1016f4ec3c59ce33d6274ae6acda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
.section .text

.global _start
_start:
    # Set up end of the stack frame linked list.
    movl $0, %ebp
    pushl %ebp # rip=0
    pushl %ebp # rbp=0
    movl %esp, %ebp

    # We need those in a moment when we call main.
    pushl %esi
    pushl %edi

    # Prepare signals, memory allocation, stdio and such.
#    call initialize_standard_library

    # Run the global constructors.
    call _init

    # Restore argc and argv.
    popl %edi
    popl %esi

    # Run main
    call main

    # Terminate the process with the exit code.
    movl %eax, %edi
#    call exit
.size _start, . - _start