crt1.S 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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, see <http://www.gnu.org/licenses/>. */
  14. #include <features.h>
  15. .global _start
  16. .global __exit
  17. .global atexit
  18. .global main
  19. #ifdef __H8300S__
  20. .h8300s
  21. #else
  22. .h8300h
  23. #endif
  24. /*
  25. void __uClibc_main(int (*main)(int, char **, char **), int argc,
  26. char **argv, void (*app_init)(void), void (*app_fini)(void),
  27. void (*rtld_fini)(void),void *stack_end attribute_unused)
  28. */
  29. .text
  30. _start: /* put here so that references to _start work with elf-PIC */
  31. mov.l @sp+,er1 /* argc */
  32. mov.l @sp+,er2 /* argv */
  33. add.l #4,sp
  34. #if !defined(__PIC__)
  35. mov.l sp, @-sp
  36. sub.l er0,er0
  37. mov.l er0,@-sp
  38. mov.l #_fini,er0
  39. mov.l er0,@-sp
  40. mov.l #_init,er0
  41. mov.l er0,@-sp
  42. mov.l #main,er0
  43. jsr @__uClibc_main
  44. #else
  45. mov.l sp, @-sp
  46. sub.l er0,er0
  47. mov.l er0,@-sp
  48. mov.l @(_fini@GOTOFF,er5),er0
  49. mov.l er0,@-sp
  50. mov.l @(_init@GOTOFF,er5),er0
  51. mov.l er0,@-sp
  52. mov.l @(main@GOTOFF,er5),er0
  53. mov.l @(__uClibc_main@GOTOFF,er5),er3
  54. jsr @er3
  55. #endif
  56. /* If that didn't kill us, ... */
  57. __exit:
  58. mov.l er0,er1
  59. sub.l er0,er0
  60. inc.l #1,er0 /* __NR_exit */
  61. trapa #0
  62. /*
  63. * this was needed for gcc/g++-builds, atexit was not getting included
  64. * for some stupid reason, this gets us a compiler
  65. */
  66. empty_func:
  67. rts
  68. .weak atexit
  69. atexit = empty_func
  70. /* Define a symbol for the first piece of initialized data. */
  71. .data
  72. .globl _data_start
  73. _data_start:
  74. .long 0
  75. .weak data_start
  76. data_start = _data_start