pt-initfini.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* Special .init and .fini section support for SH. Linuxthread version.
  2. Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it
  5. and/or modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. In addition to the permissions in the GNU Lesser General Public
  9. License, the Free Software Foundation gives you unlimited
  10. permission to link the compiled version of this file with other
  11. programs, and to distribute those programs without any restriction
  12. coming from the use of this file. (The Lesser General Public
  13. License restrictions do apply in other respects; for example, they
  14. cover modification of the file, and distribution when not linked
  15. into another program.)
  16. The GNU C Library is distributed in the hope that it will be
  17. useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  18. of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. GNU Lesser General Public License for more details.
  20. You should have received a copy of the GNU Lesser General Public
  21. License along with the GNU C Library; see the file COPYING.LIB. If not,
  22. write to the Free Software Foundation, 59 Temple Place - Suite 330,
  23. Boston, MA 02111-1307, USA. */
  24. /* This file is compiled into assembly code which is then munged by a sed
  25. script into two files: crti.s and crtn.s.
  26. * crti.s puts a function prologue at the beginning of the
  27. .init and .fini sections and defines global symbols for
  28. those addresses, so they can be called as functions.
  29. * crtn.s puts the corresponding function epilogues
  30. in the .init and .fini sections. */
  31. __asm__ ("\n\
  32. \n\
  33. #include \"defs.h\"\n\
  34. \n\
  35. /*@HEADER_ENDS*/\n\
  36. \n\
  37. /*@TESTS_BEGIN*/\n\
  38. \n\
  39. /*@TESTS_END*/\n\
  40. \n\
  41. /*@_init_PROLOG_BEGINS*/\n\
  42. .section .init\n\
  43. .align 5\n\
  44. .global _init\n\
  45. .type _init,@function\n\
  46. _init:\n\
  47. mov.l r12,@-r15\n\
  48. mov.l r14,@-r15\n\
  49. sts.l pr,@-r15\n\
  50. mova .L22,r0\n\
  51. mov.l .L22,r12\n\
  52. add r0,r12\n\
  53. mova .L24,r0\n\
  54. mov.l .L24,r1\n\
  55. add r0,r1\n\
  56. jsr @r1\n\
  57. nop\n\
  58. mova .L23,r0\n\
  59. mov.l .L23,r1\n\
  60. add r0,r1\n\
  61. jsr @r1\n\
  62. mov r15,r14\n\
  63. bra 1f\n\
  64. nop\n\
  65. .align 2\n\
  66. .L22:\n\
  67. .long _GLOBAL_OFFSET_TABLE_\n\
  68. .L23:\n\
  69. .long __gmon_start__@PLT\n\
  70. .L24:\n\
  71. .long __pthread_initialize_minimal@PLT\n\
  72. 1:\n\
  73. ALIGN\n\
  74. END_INIT\n\
  75. \n\
  76. /*@_init_PROLOG_ENDS*/\n\
  77. \n\
  78. /*@_init_EPILOG_BEGINS*/\n\
  79. .section .init\n\
  80. mov r14,r15\n\
  81. lds.l @r15+,pr\n\
  82. mov.l @r15+,r14\n\
  83. rts \n\
  84. mov.l @r15+,r12\n\
  85. END_INIT\n\
  86. .section .text\n\
  87. .align 5\n\
  88. .weak __gmon_start__\n\
  89. .type __gmon_start__,@function\n\
  90. __gmon_start__:\n\
  91. mov.l r14,@-r15\n\
  92. mov r15,r14\n\
  93. mov r14,r15\n\
  94. rts \n\
  95. mov.l @r15+,r14\n\
  96. \n\
  97. /*@_init_EPILOG_ENDS*/\n\
  98. \n\
  99. /*@_fini_PROLOG_BEGINS*/\n\
  100. .section .fini\n\
  101. .align 5\n\
  102. .global _fini\n\
  103. .type _fini,@function\n\
  104. _fini:\n\
  105. mov.l r12,@-r15\n\
  106. mov.l r14,@-r15\n\
  107. sts.l pr,@-r15\n\
  108. mova .L27,r0\n\
  109. mov.l .L27,r12\n\
  110. add r0,r12\n\
  111. mov r15,r14\n\
  112. ALIGN\n\
  113. END_FINI\n\
  114. bra 1f\n\
  115. nop\n\
  116. .align 2\n\
  117. .L27:\n\
  118. .long _GLOBAL_OFFSET_TABLE_\n\
  119. 1:\n\
  120. /*@_fini_PROLOG_ENDS*/\n\
  121. \n\
  122. /*@_fini_EPILOG_BEGINS*/\n\
  123. .section .fini\n\
  124. mov r14,r15\n\
  125. lds.l @r15+,pr\n\
  126. mov.l @r15+,r14\n\
  127. rts \n\
  128. mov.l @r15+,r12\n\
  129. \n\
  130. END_FINI\n\
  131. \n\
  132. /*@_fini_EPILOG_ENDS*/\n\
  133. \n\
  134. /*@TRAILER_BEGINS*/\n\
  135. ");