crt1.s 878 B

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