crt0.S 884 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* When we enter this piece of code, the program stack looks like this:
  2. argc argument counter (integer)
  3. argv[0] program name (pointer)
  4. argv[1...N] program args (pointers)
  5. argv[argc-1] end of args (integer)
  6. NULL
  7. env[0...N] environment variables (pointers)
  8. NULL
  9. */
  10. #include <features.h>
  11. #include "regdef.h"
  12. .text
  13. .global __start
  14. .type __start,@function
  15. __start:
  16. #ifdef __PIC__
  17. .set noreorder
  18. bltzal zero,0f
  19. nop
  20. 0: .cpload $31
  21. .set reorder
  22. #endif
  23. move $31, zero
  24. lw a0, 0($29) /* argc */
  25. addu a1, $29, 4 /* argv */
  26. addu a2, a0, 1 /* load envp */
  27. sll a2, a2, 2
  28. add a2, a2, a1
  29. /* Ok, now run uClibc's main() -- shouldn't return */
  30. jal __uClibc_main
  31. hlt: b hlt /* Crash if somehow it does return. */