crt0.S 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. .global main
  20. #ifdef __H8300S__
  21. .h8300s
  22. #else
  23. .h8300h
  24. #endif
  25. .text
  26. _start: /* put here so that references to _start work with elf-PIC */
  27. mov.l @(0,sp),er0 /* argc */
  28. mov.l @(4,sp),er1 /* argv */
  29. mov.l @(8,sp),er2 /* envp */
  30. #if !defined(__PIC__)
  31. jsr @___uClibc_main
  32. #else
  33. mov.l @(___uClibc_main@GOTOFF,er5),er3
  34. jsr @er3
  35. #endif
  36. /* If that didn't kill us, ... */
  37. __exit:
  38. mov.l er0,er1
  39. sub.l er0,er0
  40. inc.l #1,er0 /* __NR_exit */
  41. trapa #0
  42. /*
  43. * this was needed for gcc/g++-builds, atexit was not getting included
  44. * for some stupid reason, this gets us a compiler
  45. */
  46. empty_func:
  47. rts
  48. .weak atexit
  49. atexit = empty_func
  50. /* Define a symbol for the first piece of initialized data. */
  51. .data
  52. .globl __data_start
  53. __data_start:
  54. .long 0
  55. .weak data_start
  56. data_start = __data_start