crt1.S 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * crt0 for VAX
  3. */
  4. /*
  5. * Program stack looks like:
  6. * sp-> argc argument counter (integer)
  7. * argv[0] program name (pointer)
  8. * argv[1...N] program args (pointers)
  9. * argv[argc-1] end of args (integer)
  10. * NULL
  11. * env[0...N] environment variables (pointers)
  12. * NULL
  13. */
  14. #include <features.h>
  15. .text
  16. .align 4
  17. .global __start
  18. __start:
  19. .global _start
  20. _start:
  21. /* Kernel uses a_interp + 2, so __start isn't exactly CALLSed, */
  22. /* but we need to have two bytes here, so we use NOPs. This */
  23. /* won't hurt, though R0 would be invalid to push, but at */
  24. /* lease this looks like a real function. */
  25. .word 0x0101
  26. movl $0, %fp /* FP = 0, since this is the */
  27. /* top-most stack frame */
  28. movl %sp, %r0 /* R0 = %sp */
  29. movl (%sp)+, %r4 /* R4 = argc */
  30. movl %sp, %r3 /* R3 = argv = &argv[0] */
  31. #if (defined L_crt1 || defined L_gcrt1) && defined __UCLIBC_CTOR_DTOR__
  32. pushl %r0 /* stack_end */
  33. pushl $0 /* rtld_fini. This is probably needed for the */
  34. /* case where a dynamic linker is involved. So */
  35. /* this is an open FIXME that needs to be */
  36. /* addressed at some time... */
  37. pushl $_fini
  38. pushl $_init
  39. pushl %r3 /* Argument pointer */
  40. pushl %r4 /* And the argument count */
  41. pushl $main /* main() */
  42. /* We need to call __uClibc_main which should not return.
  43. * __uClibc_main (int (*main) (int, char **, char **),
  44. * int argc,
  45. * char **argv,
  46. * void (*init) (void),
  47. * void (*fini) (void),
  48. * void (*rtld_fini) (void),
  49. * void *stack_end);
  50. */
  51. calls $7, __uClibc_main
  52. #else /* FIXME: THIS IS BROKEN!!! */
  53. /* start to load the arguments from the stack */
  54. /* arguments are on ap stack */
  55. pushl %r2
  56. pushl %r3
  57. pushl %r4
  58. calls $3, __uClibc_main
  59. #endif
  60. /* The above __uClibc_start_main() shouldn't ever return. If it */
  61. /* does, we just crash. */
  62. halt
  63. .align 2