pt-initfini.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* Special .init and .fini section support for SH. NPTL version.
  2. Copyright (C) 2003, 2009 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 Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. In addition to the permissions in the GNU Library 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 Library 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 Library General Public License for more details.
  20. You should have received a copy of the GNU Library General Public
  21. License along with the GNU C Library; see the file COPYING.LIB. If not,
  22. see <http://www.gnu.org/licenses/>. */
  23. /* This file is compiled into assembly code which is then munged by a sed
  24. script into two files: crti.s and crtn.s.
  25. * crti.s puts a function prologue at the beginning of the
  26. .init and .fini sections and defines global symbols for
  27. those addresses, so they can be called as functions.
  28. * crtn.s puts the corresponding function epilogues
  29. in the .init and .fini sections. */
  30. __asm__ ("\n\
  31. \n\
  32. #include \"defs.h\"\n\
  33. \n\
  34. /*@HEADER_ENDS*/\n\
  35. \n\
  36. /*@TESTS_BEGIN*/\n\
  37. \n\
  38. /*@TESTS_END*/\n\
  39. \n\
  40. /*@_init_PROLOG_BEGINS*/\n\
  41. .section .init\n\
  42. .align 5\n\
  43. .global _init\n\
  44. .type _init,@function\n\
  45. _init:\n\
  46. mov.l r12,@-r15\n\
  47. mov.l r14,@-r15\n\
  48. sts.l pr,@-r15\n\
  49. mova .L22,r0\n\
  50. mov.l .L22,r12\n\
  51. add r0,r12\n\
  52. mova .L24,r0\n\
  53. mov.l .L24,r1\n\
  54. add r0,r1\n\
  55. jsr @r1\n\
  56. mov r15,r14\n\
  57. bra 1f\n\
  58. nop\n\
  59. .align 2\n\
  60. .L22:\n\
  61. .long _GLOBAL_OFFSET_TABLE_\n\
  62. .L24:\n\
  63. .long __pthread_initialize_minimal_internal@PLT\n\
  64. 1:\n\
  65. ALIGN\n\
  66. END_INIT\n\
  67. \n\
  68. /*@_init_PROLOG_ENDS*/\n\
  69. \n\
  70. /*@_init_EPILOG_BEGINS*/\n\
  71. .section .init\n\
  72. mov r14,r15\n\
  73. lds.l @r15+,pr\n\
  74. mov.l @r15+,r14\n\
  75. rts \n\
  76. mov.l @r15+,r12\n\
  77. END_INIT\n\
  78. \n\
  79. /*@_init_EPILOG_ENDS*/\n\
  80. \n\
  81. /*@_fini_PROLOG_BEGINS*/\n\
  82. .section .fini\n\
  83. .align 5\n\
  84. .global _fini\n\
  85. .type _fini,@function\n\
  86. _fini:\n\
  87. mov.l r12,@-r15\n\
  88. mov.l r14,@-r15\n\
  89. sts.l pr,@-r15\n\
  90. mova .L27,r0\n\
  91. mov.l .L27,r12\n\
  92. add r0,r12\n\
  93. mov r15,r14\n\
  94. ALIGN\n\
  95. END_FINI\n\
  96. bra 1f\n\
  97. nop\n\
  98. .align 2\n\
  99. .L27:\n\
  100. .long _GLOBAL_OFFSET_TABLE_\n\
  101. 1:\n\
  102. /*@_fini_PROLOG_ENDS*/\n\
  103. \n\
  104. /*@_fini_EPILOG_BEGINS*/\n\
  105. .section .fini\n\
  106. mov r14,r15\n\
  107. lds.l @r15+,pr\n\
  108. mov.l @r15+,r14\n\
  109. rts \n\
  110. mov.l @r15+,r12\n\
  111. \n\
  112. END_FINI\n\
  113. \n\
  114. /*@_fini_EPILOG_ENDS*/\n\
  115. \n\
  116. /*@TRAILER_BEGINS*/\n\
  117. ");