pt-initfini.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* Special .init and .fini section support for HPPA. Linuxthreads version.
  2. Copyright (C) 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. /* If we use the standard C version, the linkage table pointer won't
  32. be properly preserved due to the splitting up of function prologues
  33. and epilogues. Therefore we write these in assembly to make sure
  34. they do the right thing. */
  35. __asm__ (
  36. "#include \"defs.h\"\n"
  37. "\n"
  38. "/*@HEADER_ENDS*/\n"
  39. "\n"
  40. "/*@_init_PROLOG_BEGINS*/\n"
  41. " .section .init\n"
  42. " .align 4\n"
  43. " .globl _init\n"
  44. " .type _init,@function\n"
  45. "_init:\n"
  46. " stw %rp,-20(%sp)\n"
  47. " stwm %r4,64(%sp)\n"
  48. " stw %r19,-32(%sp)\n"
  49. " bl __pthread_initialize_minimal,%rp\n"
  50. " copy %r19,%r4 /* delay slot */\n"
  51. " copy %r4,%r19\n"
  52. "/*@_init_PROLOG_ENDS*/\n"
  53. "\n"
  54. "/*@_init_EPILOG_BEGINS*/\n"
  55. "/* Here is the tail end of _init. */\n"
  56. " .section .init\n"
  57. " ldw -84(%sp),%rp\n"
  58. " copy %r4,%r19\n"
  59. " bv %r0(%rp)\n"
  60. "_end_init:\n"
  61. " ldwm -64(%sp),%r4\n"
  62. "\n"
  63. "/* Our very own unwind info, because the assembler can't handle\n"
  64. " functions split into two or more pieces. */\n"
  65. " .section .PARISC.unwind,\"a\",@progbits\n"
  66. " .extern _init\n"
  67. " .word _init, _end_init\n"
  68. " .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
  69. "\n"
  70. "/*@_init_EPILOG_ENDS*/\n"
  71. "\n"
  72. "/*@_fini_PROLOG_BEGINS*/\n"
  73. " .section .fini\n"
  74. " .align 4\n"
  75. " .globl _fini\n"
  76. " .type _fini,@function\n"
  77. "_fini:\n"
  78. " stw %rp,-20(%sp)\n"
  79. " stwm %r4,64(%sp)\n"
  80. " stw %r19,-32(%sp)\n"
  81. " copy %r19,%r4\n"
  82. "/*@_fini_PROLOG_ENDS*/\n"
  83. "\n"
  84. "/*@_fini_EPILOG_BEGINS*/\n"
  85. " .section .fini\n"
  86. " ldw -84(%sp),%rp\n"
  87. " copy %r4,%r19\n"
  88. " bv %r0(%rp)\n"
  89. "_end_fini:\n"
  90. " ldwm -64(%sp),%r4\n"
  91. "\n"
  92. " .section .PARISC.unwind,\"a\",@progbits\n"
  93. " .extern _fini\n"
  94. " .word _fini, _end_fini\n"
  95. " .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
  96. "\n"
  97. "/*@_fini_EPILOG_ENDS*/\n"
  98. "\n"
  99. "/*@TRAILER_BEGINS*/\n"
  100. );