crt0.c 1.5 KB

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