crt0.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Startup code compliant to the ELF CRIS ABI */
  2. /* The first piece of initialized data. */
  3. int __data_start = 0;
  4. /*
  5. * It is important that this be the first function.
  6. * This file is the first thing in the text section.
  7. */
  8. void
  9. _start ()
  10. {
  11. /*
  12. * On the stack we have argc. We can calculate argv/envp
  13. * from that and the succeeding stack location, but fix so
  14. * we get the right calling convention (regs in r10/r11).
  15. *
  16. * Please view linux/fs/binfmt_elf.c for a complete
  17. * understanding of this.
  18. */
  19. __asm__ volatile("pop $r10");
  20. __asm__ volatile("move.d $sp, $r11");
  21. __asm__ volatile("jump start1");
  22. }
  23. void __uClibc_main(int argc, char **argv, char **envp)
  24. __attribute__ ((__noreturn__));
  25. static void
  26. start1 (int argc, char **argv)
  27. {
  28. char** environ;
  29. /* The environment starts just after ARGV. */
  30. environ = &argv[argc + 1];
  31. /*
  32. * If the first thing after ARGV is the arguments
  33. * themselves, there is no environment.
  34. */
  35. if ((char *) environ == *argv)
  36. /*
  37. * The environment is empty. Make environ
  38. * point at ARGV[ARGC], which is NULL.
  39. */
  40. --environ;
  41. /* Leave control to the libc */
  42. __uClibc_main(argc, argv, environ);
  43. }