crt0.S 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public License as
  5. published by the Free Software Foundation; either version 2 of the
  6. License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with the GNU C Library; see the file COPYING.LIB. If
  13. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  14. Cambridge, MA 02139, USA. */
  15. #include <features.h>
  16. .global _start
  17. .global __exit
  18. .global atexit
  19. .h8300h
  20. .text
  21. _start: /* put here so that references to _start work with elf-PIC */
  22. mov.l @(0,sp),er0 /* argc */
  23. mov.l @(4,sp),er1 /* argv */
  24. mov.l @(8,sp),er2 /* envp */
  25. jsr @___uClibc_main
  26. /* If that didn't kill us, ... */
  27. __exit:
  28. mov.l er0,er1
  29. sub.l er0,er0
  30. inc.l #1,er0 /* __NR_exit */
  31. trapa #0
  32. /*
  33. * this was needed for gcc/g++-builds, atexit was not getting included
  34. * for some stupid reason, this gets us a compiler
  35. */
  36. empty_func:
  37. rts
  38. #if defined(HAVE_ELF)
  39. .weak atexit
  40. atexit = empty_func
  41. #else
  42. .set atexit,empty_func
  43. #endif
  44. /* Stick in a dummy reference to main(), so that if an application
  45. * is linking when the main() function is in a static library (.a)
  46. * we can be sure that main() actually gets linked in */
  47. L_dummy_main_reference:
  48. .long _main