pt-initfini.c 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* Special .init and .fini section support for Alpha. NPTL version.
  2. Copyright (C) 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 and/or
  5. 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. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. /* This file is compiled into assembly code which is then munged by a sed
  16. script into two files: crti.s and crtn.s.
  17. * crti.s puts a function prologue at the beginning of the .init and .fini
  18. sections and defines global symbols for those addresses, so they can be
  19. called as functions.
  20. * crtn.s puts the corresponding function epilogues in the .init and .fini
  21. sections.
  22. This differs from what would be generated by the generic code in that
  23. we save and restore the GP within the function. In order for linker
  24. relaxation to work, the value in the GP register on exit from a function
  25. must be valid for the function entry point. Normally, a function is
  26. contained within one object file and this is not an issue, provided
  27. that the function reloads the gp after making any function calls.
  28. However, _init and _fini are constructed from pieces of many object
  29. files, all of which may have different GP values. So we must reload
  30. the GP value from crti.o in crtn.o. */
  31. __asm__ (" \n\
  32. #include \"defs.h\" \n\
  33. \n\
  34. /*@HEADER_ENDS*/ \n\
  35. \n\
  36. /*@_init_PROLOG_BEGINS*/ \n\
  37. .section .init, \"ax\", @progbits \n\
  38. .globl _init \n\
  39. .type _init,@function \n\
  40. .usepv _init,std \n\
  41. _init: \n\
  42. ldgp $29, 0($27) \n\
  43. subq $30, 16, $30 \n\
  44. stq $26, 0($30) \n\
  45. stq $29, 8($30) \n\
  46. bsr $26, __pthread_initialize_minimal_internal !samegp \n\
  47. .align 3 \n\
  48. /*@_init_PROLOG_ENDS*/ \n\
  49. \n\
  50. /*@_init_EPILOG_BEGINS*/ \n\
  51. .section .init, \"ax\", @progbits \n\
  52. ldq $26, 0($30) \n\
  53. ldq $29, 8($30) \n\
  54. addq $30, 16, $30 \n\
  55. ret \n\
  56. /*@_init_EPILOG_ENDS*/ \n\
  57. \n\
  58. /*@_fini_PROLOG_BEGINS*/ \n\
  59. .section .fini, \"ax\", @progbits \n\
  60. .globl _fini \n\
  61. .type _fini,@function \n\
  62. .usepv _fini,std \n\
  63. _fini: \n\
  64. ldgp $29, 0($27) \n\
  65. subq $30, 16, $30 \n\
  66. stq $26, 0($30) \n\
  67. stq $29, 8($30) \n\
  68. .align 3 \n\
  69. /*@_fini_PROLOG_ENDS*/ \n\
  70. \n\
  71. /*@_fini_EPILOG_BEGINS*/ \n\
  72. .section .fini, \"ax\", @progbits \n\
  73. ldq $26, 0($30) \n\
  74. ldq $29, 8($30) \n\
  75. addq $30, 16, $30 \n\
  76. ret \n\
  77. /*@_fini_EPILOG_ENDS*/ \n\
  78. \n\
  79. /*@TRAILER_BEGINS*/ \n\
  80. ");