pt-initfini.c 3.1 KB

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