crt0.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * uClibc/sysdeps/linux/i386/crt0.S
  3. * Pull stuff off the stack and get uClibc moving.
  4. *
  5. * Copyright (C) 2001 by Lineo, inc.
  6. * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
  7. * who is very pleased he managed to do this entirely in C code.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU Library General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
  17. * for more details.
  18. *
  19. * You should have received a copy of the GNU Library General Public License
  20. * along with this program; if not, write to the Free Software Foundation,
  21. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. extern void __uClibc_main(int argc,void *argv,void *envp);
  25. void _start(unsigned int first_arg)
  26. {
  27. unsigned int argc;
  28. char **argv, **envp;
  29. unsigned long *stack;
  30. stack = (unsigned long*) &first_arg;
  31. argc = *(stack - 1);
  32. argv = (char **) stack;
  33. envp = (char **)stack + argc + 1;
  34. __uClibc_main(argc, argv, envp);
  35. }