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. /* Stick in a dummy reference to main(), so that if an application
  22. * is linking when the main() function is in a static library (.a)
  23. * we can be sure that main() actually gets linked in */
  24. extern void main(int argc,void *argv,void *envp);
  25. void (*mainp)(int argc,void *argv,void *envp) = main;
  26. extern void __uClibc_main(int argc,void *argv,void *envp);
  27. void _start(void)
  28. {
  29. unsigned int argc;
  30. char **argv, **envp;
  31. unsigned long *stack;
  32. stack = ((unsigned long*)__builtin_frame_address(0))+16;
  33. argc = *stack;
  34. argv = (char **)stack + 1;
  35. envp = (char **)stack + argc + 2;
  36. __uClibc_main(argc, argv, envp);
  37. }