794b6f711773add72baff9926344b3cd0e49f05c
[musl] / crt / mips / crt1.s
1 .set noreorder
2
3 .weak  _init
4 .weak  _fini
5 .global __start
6 .global _start
7 .type __start,@function
8 .type _start,@function
9 __start:
10 _start:
11         subu    $fp, $fp, $fp            # Zero the frame pointer.
12         lui     $gp, %hi(_gp)
13         addi    $gp, %lo(_gp)
14         #la      $gp, _gp
15         lw      $4, %call16(main)($gp)   # Get main() ...
16         lw      $5, ($sp)                # Get argc...
17         addu    $6, $sp, 4               # and argv ...
18         lw      $7, %call16(_init)($gp)  # and _init() ...
19         and     $sp, $sp, -8             # Align the stack pointer to 8 bytes
20         addi    $sp, $sp, -4*6           # Leave space for arguments 0..3, arg4, and arg5.
21         lw      $12, %call16(_fini)($gp) # and _fini() ...
22         sw      $12, 4*4($sp)            # Save arg4.
23         sw      $0, 4*5($sp)             # ldso_fini == NULL
24         lw      $25, %call16(__libc_start_main)($gp)
25         jalr    $25                      # Let's go!
26         nop
27         b       .                        # Never gets here.
28         nop