crt0.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. /* a little bit of stuff to support C++ */
  26. __asm__(".section .ctors,\"aw\"\n.align 4\n.global __CTOR_LIST__\n"
  27. "__CTOR_LIST__:\n.long -1\n");
  28. __asm__(".section .dtors,\"aw\"\n.align 4\n.global __DTOR_LIST__\n"
  29. "__DTOR_LIST__:\n.long -1\n");
  30. void _start(unsigned int first_arg)
  31. {
  32. unsigned int argc;
  33. char **argv, **envp;
  34. unsigned long *stack;
  35. stack = (unsigned long*) &first_arg;
  36. argc = *(stack - 1);
  37. argv = (char **) stack;
  38. envp = (char **)stack + argc + 1;
  39. __uClibc_main(argc, argv, envp);
  40. }