crt1.S 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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, write to the Free
  29. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  30. 02111-1307 USA. */
  31. .import main, code
  32. .import $global$, data
  33. .import __uClibc_main, code
  34. #if defined(__UCLIBC_CTOR_DTOR__)
  35. .import _fini, code
  36. .import _init, code
  37. #else
  38. .weak _fini
  39. .weak _init
  40. #endif
  41. /* Have the linker create plabel words
  42. so we get PLABEL32 relocs and not 21/14 */
  43. .section .rodata
  44. .align 4
  45. .Lpmain:
  46. .word P%main
  47. .Lp__uClibc_main:
  48. .word P%__uClibc_main
  49. .Lp_fini:
  50. .word P%_fini
  51. .Lp_init:
  52. .word P%_init
  53. .text
  54. .align 4
  55. .globl _start
  56. .export _start, ENTRY
  57. .type _start,@function
  58. _start:
  59. .proc
  60. .callinfo
  61. /* Expand the stack to store the 5th through 7th args */
  62. ldo 64(%sp), %sp
  63. /* TODO: Follow ABI? Place more things on the stack here... */
  64. #ifdef __PIC__
  65. /* load main (1st argument) */
  66. addil LR'.Lpmain, %r19
  67. ldw RR'.Lpmain(%r1), %r26
  68. ldw 0(%r26),%r26
  69. /* argc and argv should be in 25 and 24 (2nd and 3rd argument) */
  70. /* void (*init) (void) (4th argument) */
  71. addil LR'.Lp_init, %r19
  72. ldw RR'.Lp_init(%r1), %r23
  73. ldw 0(%r23), %r23
  74. /* void (*fini) (void) (5th argument) */
  75. addil LR'.Lp_fini, %r19
  76. ldw RR'.Lp_fini(%r1), %r22
  77. ldw 0(%r22), %r22
  78. #else
  79. /* load main (1st argument) */
  80. ldil LR'.Lpmain, %r26
  81. ldw RR'.Lpmain(%r26), %r26
  82. /* argc and argv should be in 25 and 24 (2nd and 3rd argument) */
  83. /* void (*init) (void) (4th argument) */
  84. ldil LR'.Lp_init, %r23
  85. ldw RR'.Lp_init(%r23), %r23
  86. /* void (*fini) (void) (5th argument) */
  87. ldil LR'.Lp_fini, %r22
  88. ldw RR'.Lp_fini(%r22), %r22
  89. #endif
  90. /* Store 5th argument */
  91. stw %r22, -52(%sp)
  92. /* void (*rtld_fini) (void) (6th argument) */
  93. stw %r23, -56(%sp)
  94. /* void *stack_end (7th argument) */
  95. stw %sp, -60(%sp)
  96. /* load global */
  97. ldil L%$global$, %dp
  98. ldo R%$global$(%dp), %dp
  99. bl __uClibc_main,%r2
  100. nop
  101. /* die horribly if it returned (it shouldn't) */
  102. iitlbp %r0,(%sr0,%r0)
  103. nop
  104. .procend
  105. /* Define a symbol for the first piece of initialized data. */
  106. .data
  107. .globl __data_start
  108. __data_start:
  109. .long 0
  110. .weak data_start
  111. data_start = __data_start