crt0.S 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. */
  32. #if 0 /* this should be provided by crtbegin/crtend in the compiler */
  33. /* a little bit of stuff to support C++ */
  34. .section .ctors,"aw"
  35. .align 4
  36. .global __CTOR_LIST__
  37. __CTOR_LIST__:
  38. .long -1
  39. .section .dtors,"aw"
  40. .align 4
  41. .global __DTOR_LIST__
  42. __DTOR_LIST__:
  43. .long -1
  44. #endif