pt-initfini.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /* Special .init and .fini section support for ia64. LinuxThreads version.
  2. Copyright (C) 2000, 2001, 2002, 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. #include <stddef.h>
  32. #ifdef HAVE_INITFINI_ARRAY
  33. # define INIT_NEW_WAY \
  34. ".xdata8 \".init_array\", @fptr(__pthread_initialize_minimal)\n"
  35. # define INIT_OLD_WAY ""
  36. #else
  37. # define INIT_NEW_WAY ""
  38. # define INIT_OLD_WAY \
  39. "\n\
  40. st8 [r12] = gp, -16\n\
  41. br.call.sptk.many b0 = __pthread_initialize_minimal# ;;\n\
  42. ;;\n\
  43. adds r12 = 16, r12\n\
  44. ;;\n\
  45. ld8 gp = [r12]\n\
  46. ;;\n"
  47. #endif
  48. __asm__ ("\n\
  49. \n\
  50. #include \"defs.h\"\n\
  51. \n\
  52. /*@HEADER_ENDS*/\n\
  53. \n\
  54. /*@_init_PROLOG_BEGINS*/\n"
  55. INIT_NEW_WAY
  56. ".section .init\n\
  57. .align 16\n\
  58. .global _init#\n\
  59. .proc _init#\n\
  60. _init:\n\
  61. .prologue\n\
  62. .save ar.pfs, r34\n\
  63. alloc r34 = ar.pfs, 0, 3, 0, 0\n\
  64. .vframe r32\n\
  65. mov r32 = r12\n\
  66. .save rp, r33\n\
  67. mov r33 = b0\n\
  68. .body\n\
  69. adds r12 = -16, r12\n\
  70. ;;\n"
  71. INIT_OLD_WAY
  72. ".endp _init#\n\
  73. \n\
  74. /*@_init_PROLOG_ENDS*/\n\
  75. \n\
  76. /*@_init_EPILOG_BEGINS*/\n\
  77. .section .init\n\
  78. .proc _init#\n\
  79. _init:\n\
  80. .prologue\n\
  81. .save ar.pfs, r34\n\
  82. .vframe r32\n\
  83. .save rp, r33\n\
  84. .body\n\
  85. mov r12 = r32\n\
  86. mov ar.pfs = r34\n\
  87. mov b0 = r33\n\
  88. br.ret.sptk.many b0\n\
  89. .endp _init#\n\
  90. /*@_init_EPILOG_ENDS*/\n\
  91. \n\
  92. /*@_fini_PROLOG_BEGINS*/\n\
  93. .section .fini\n\
  94. .align 16\n\
  95. .global _fini#\n\
  96. .proc _fini#\n\
  97. _fini:\n\
  98. .prologue\n\
  99. .save ar.pfs, r34\n\
  100. alloc r34 = ar.pfs, 0, 3, 0, 0\n\
  101. .vframe r32\n\
  102. mov r32 = r12\n\
  103. .save rp, r33\n\
  104. mov r33 = b0\n\
  105. .body\n\
  106. adds r12 = -16, r12\n\
  107. ;;\n\
  108. .endp _fini#\n\
  109. \n\
  110. /*@_fini_PROLOG_ENDS*/\n\
  111. \n\
  112. /*@_fini_EPILOG_BEGINS*/\n\
  113. .section .fini\n\
  114. .proc _fini#\n\
  115. _fini:\n\
  116. .prologue\n\
  117. .save ar.pfs, r34\n\
  118. .vframe r32\n\
  119. .save rp, r33\n\
  120. .body\n\
  121. mov r12 = r32\n\
  122. mov ar.pfs = r34\n\
  123. mov b0 = r33\n\
  124. br.ret.sptk.many b0\n\
  125. .endp _fini#\n\
  126. \n\
  127. /*@_fini_EPILOG_ENDS*/\n\
  128. \n\
  129. /*@TRAILER_BEGINS*/\n\
  130. .weak __gmon_start__#\n\
  131. ");