pt-initfini.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. /* This file is compiled into assembly code which is then munged by a sed
  17. script into two files: crti.s and crtn.s.
  18. * crti.s puts a function prologue at the beginning of the .init and .fini
  19. sections and defines global symbols for those addresses, so they can be
  20. called as functions.
  21. * crtn.s puts the corresponding function epilogues in the .init and .fini
  22. sections.
  23. This differs from what would be generated by the generic code in that
  24. we save and restore the GP within the function. In order for linker
  25. relaxation to work, the value in the GP register on exit from a function
  26. must be valid for the function entry point. Normally, a function is
  27. contained within one object file and this is not an issue, provided
  28. that the function reloads the gp after making any function calls.
  29. However, _init and _fini are constructed from pieces of many object
  30. files, all of which may have different GP values. So we must reload
  31. the GP value from crti.o in crtn.o. */
  32. __asm__ (" \n\
  33. #include \"defs.h\" \n\
  34. \n\
  35. /*@HEADER_ENDS*/ \n\
  36. \n\
  37. /*@_init_PROLOG_BEGINS*/ \n\
  38. .section .init, \"ax\", @progbits \n\
  39. .globl _init \n\
  40. .type _init,@function \n\
  41. .usepv _init,std \n\
  42. _init: \n\
  43. ldgp $29, 0($27) \n\
  44. subq $30, 16, $30 \n\
  45. stq $26, 0($30) \n\
  46. stq $29, 8($30) \n\
  47. bsr $26, __pthread_initialize_minimal_internal !samegp \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. ");