crt0.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* $Id: crt0.c,v 1.1 2002/09/16 08:08:33 tobiasa Exp $ */
  2. /* C base for Linux/CRIS 2.0/2.4
  3. */
  4. //#define DEBUG
  5. /* The first piece of initialized data. */
  6. int __data_start = 0;
  7. /* N.B.: It is important that this be the first function.
  8. This file is the first thing in the text section. */
  9. void
  10. _start ()
  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. * to understand this you really ought to read fs/binfmt_elf.c
  17. */
  18. __asm__ volatile("pop $r10");
  19. __asm__ volatile("move.d $sp, $r11");
  20. __asm__ volatile("jump start1");
  21. }
  22. void __uClibc_main(int argc, char **argv, char **envp)
  23. __attribute__ ((__noreturn__));
  24. static void
  25. start1 (int argc, char **argv)
  26. {
  27. char** environ;
  28. /* The environment starts just after ARGV. */
  29. environ = &argv[argc + 1];
  30. /* If the first thing after ARGV is the arguments
  31. themselves, there is no environment. */
  32. if ((char *) environ == *argv)
  33. /* The environment is empty. Make environ
  34. point at ARGV[ARGC], which is NULL. */
  35. --environ;
  36. /* Leave control to the libc */
  37. __uClibc_main(argc, argv, environ);
  38. }