crt0.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. .global _start
  16. .global __main
  17. .global _end
  18. /* .global __data_start */
  19. .bss
  20. .global environ
  21. environ:
  22. .long 0
  23. .text
  24. _start: /* renamed from __start */
  25. nop
  26. nop
  27. movea.l %d5, %a5
  28. lea __bss_start(%a5), %a0
  29. lea end(%a5), %a1
  30. /* Copy 0 to %a0 until %a0 == %a1 */
  31. /*
  32. From my understanding of linux/fs/binfmt_flat.c for uClinux,
  33. this is not necessary anymore. The loader will clear out
  34. the BSS for us. - jgraves@deltamobile.com
  35. L1:
  36. movel #0, %a0@+
  37. cmpal %a0, %a1
  38. bhi L1
  39. */
  40. move.l 8(%sp), %d5
  41. move.l %d5, environ(%a5)
  42. bsr main
  43. move.l %d0,%sp@-
  44. bsr exit /* Invoke exit() routine */
  45. #ifdef NO_LIBGCC
  46. /* If that didn't kill us, ... */
  47. _exit:
  48. move.l %sp@+,%d1
  49. moveq #1,%d0 /* SYS_exit */
  50. trap #0
  51. __main:
  52. rts
  53. #else
  54. .global _cleanup
  55. _cleanup:
  56. rts /* nothing to clean up */
  57. #endif /* NO_LIBGCC */