crt1.S 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* ELF startup code for HPPA.
  2. Copyright (C) 2002 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. 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 GNU 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. Note that people who make modified versions of this file are not
  17. obligated to grant this special exception for their modified
  18. versions; it is their choice whether to do so. The GNU Lesser
  19. General Public License gives permission to release a modified
  20. version without this exception; this exception also makes it
  21. possible to release a modified version which carries forward this
  22. exception.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <http://www.gnu.org/licenses/>. */
  30. .import main, code
  31. .import $global$, data
  32. .import __uClibc_main, code
  33. #if defined(__UCLIBC_CTOR_DTOR__)
  34. .import _fini, code
  35. .import _init, code
  36. #else
  37. .weak _fini
  38. .weak _init
  39. #endif
  40. /* Have the linker create plabel words
  41. so we get PLABEL32 relocs and not 21/14 */
  42. .section .rodata
  43. .align 4
  44. .Lpmain:
  45. .word P%main
  46. .Lp__uClibc_main:
  47. .word P%__uClibc_main
  48. .Lp_fini:
  49. .word P%_fini
  50. .Lp_init:
  51. .word P%_init
  52. .text
  53. .align 4
  54. .globl _start
  55. .export _start, ENTRY
  56. .type _start,@function
  57. _start:
  58. .proc
  59. .callinfo
  60. /* Expand the stack to store the 5th through 7th args */
  61. ldo 64(%sp), %sp
  62. /* TODO: Follow ABI? Place more things on the stack here... */
  63. #ifdef __PIC__
  64. /* load main (1st argument) */
  65. addil LR'.Lpmain, %r19
  66. ldw RR'.Lpmain(%r1), %r26
  67. ldw 0(%r26),%r26
  68. /* argc and argv should be in 25 and 24 (2nd and 3rd argument) */
  69. /* void (*init) (void) (4th argument) */
  70. addil LR'.Lp_init, %r19
  71. ldw RR'.Lp_init(%r1), %r23
  72. ldw 0(%r23), %r23
  73. /* void (*fini) (void) (5th argument) */
  74. addil LR'.Lp_fini, %r19
  75. ldw RR'.Lp_fini(%r1), %r22
  76. ldw 0(%r22), %r22
  77. #else
  78. /* load main (1st argument) */
  79. ldil LR'.Lpmain, %r26
  80. ldw RR'.Lpmain(%r26), %r26
  81. /* argc and argv should be in 25 and 24 (2nd and 3rd argument) */
  82. /* void (*init) (void) (4th argument) */
  83. ldil LR'.Lp_init, %r23
  84. ldw RR'.Lp_init(%r23), %r23
  85. /* void (*fini) (void) (5th argument) */
  86. ldil LR'.Lp_fini, %r22
  87. ldw RR'.Lp_fini(%r22), %r22
  88. #endif
  89. /* Store 5th argument */
  90. stw %r22, -52(%sp)
  91. /* void (*rtld_fini) (void) (6th argument) */
  92. stw %r23, -56(%sp)
  93. /* void *stack_end (7th argument) */
  94. stw %sp, -60(%sp)
  95. /* load global */
  96. ldil L%$global$, %dp
  97. ldo R%$global$(%dp), %dp
  98. bl __uClibc_main,%r2
  99. nop
  100. /* die horribly if it returned (it shouldn't) */
  101. iitlbp %r0,(%sr0,%r0)
  102. nop
  103. .procend
  104. /* Define a symbol for the first piece of initialized data. */
  105. .data
  106. .globl __data_start
  107. __data_start:
  108. .long 0
  109. .weak data_start
  110. data_start = __data_start