crt1.S 3.6 KB

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