pt-initfini.c 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Special .init and .fini section support for Alpha. Linuxthreads version.
  2. Copyright (C) 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 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. jsr $26, __pthread_initialize_minimal \n\
  47. ldq $29, 8($30) \n\
  48. .align 3 \n\
  49. /*@_init_PROLOG_ENDS*/ \n\
  50. \n\
  51. /*@_init_EPILOG_BEGINS*/ \n\
  52. .section .init, \"ax\", @progbits \n\
  53. ldq $26, 0($30) \n\
  54. ldq $29, 8($30) \n\
  55. addq $30, 16, $30 \n\
  56. ret \n\
  57. /*@_init_EPILOG_ENDS*/ \n\
  58. \n\
  59. /*@_fini_PROLOG_BEGINS*/ \n\
  60. .section .fini, \"ax\", @progbits \n\
  61. .globl _fini \n\
  62. .type _fini,@function \n\
  63. .usepv _fini,std \n\
  64. _fini: \n\
  65. ldgp $29, 0($27) \n\
  66. subq $30, 16, $30 \n\
  67. stq $26, 0($30) \n\
  68. stq $29, 8($30) \n\
  69. .align 3 \n\
  70. /*@_fini_PROLOG_ENDS*/ \n\
  71. \n\
  72. /*@_fini_EPILOG_BEGINS*/ \n\
  73. .section .fini, \"ax\", @progbits \n\
  74. ldq $26, 0($30) \n\
  75. ldq $29, 8($30) \n\
  76. addq $30, 16, $30 \n\
  77. ret \n\
  78. /*@_fini_EPILOG_ENDS*/ \n\
  79. \n\
  80. /*@TRAILER_BEGINS*/ \n\
  81. ");