cprt0.as 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Startup code for programs linked with GNU libc, PowerPC
  3. * version.
  4. *
  5. * Adapted from the glibc-sources (2.3.5) in the file
  6. *
  7. * sysdeps/powerpc/powerpc32/elf/start.S
  8. *
  9. * Original header follows.
  10. */
  11. /* Startup code for programs linked with GNU libc.
  12. Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
  13. This file is part of the GNU C Library.
  14. The GNU C Library is free software; you can redistribute it and/or
  15. modify it under the terms of the GNU Lesser General Public
  16. License as published by the Free Software Foundation; either
  17. version 2.1 of the License, or (at your option) any later version.
  18. The GNU C Library is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21. Lesser General Public License for more details.
  22. You should have received a copy of the GNU Lesser General Public
  23. License along with the GNU C Library; if not, write to the Free
  24. Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  25. 02110-1301 USA.
  26. */
  27. /* These are the various addresses we require. */
  28. .section ".rodata"
  29. .align 2
  30. start_addresses:
  31. .long _SDA_BASE_
  32. .long main_stub
  33. .long __libc_csu_init
  34. .long __libc_csu_fini
  35. .size start_adresses, .-start_addresses
  36. .section ".text"
  37. .globl _start
  38. _start:
  39. /* save stack pointer for later use */
  40. mr 9, 1
  41. /* Set up an initial stack frame, and clear the LR. */
  42. clrrwi 1, 1, 4
  43. li 0, 0
  44. stwu 1, -16(1)
  45. mtlr 0
  46. stw 0, 0(1)
  47. /* Set r13 to point at the 'small data area', and put the address of
  48. start_addresses in r8... */
  49. lis 8, start_addresses@ha
  50. lwzu 13, start_addresses@l(8)
  51. /* and continue in libc-start, in glibc. */
  52. b __libc_start_main
  53. .balign 4
  54. .globl __libc_csu_init
  55. .type __libc_csu_init,@function
  56. /* strangly enough using weak breaks things */
  57. /* .weak __libc_csu_init */
  58. __libc_csu_init:
  59. blr
  60. .Le0:
  61. .size __libc_csu_init, .Le0 - __libc_csu_init
  62. .balign 4
  63. .globl __libc_csu_fini
  64. .type __libc_csu_fini,@function
  65. /* strangly enough using weak breaks things */
  66. /* .weak __libc_csu_fini */
  67. __libc_csu_fini:
  68. blr
  69. .Le1:
  70. .size __libc_csu_fini, .Le1 - __libc_csu_fini
  71. .globl main_stub
  72. .type main_stub, @function
  73. main_stub:
  74. /* save link register and setup stack frame */
  75. mflr 0
  76. stw 0, 0(1)
  77. stwu 1, -16(1)
  78. lis 11, operatingsystem_parameter_argc@ha
  79. stw 3, operatingsystem_parameter_argc@l(11);
  80. lis 11, operatingsystem_parameter_argv@ha
  81. stw 4, operatingsystem_parameter_argv@l(11);
  82. lis 11, operatingsystem_parameter_envp@ha
  83. stw 5, operatingsystem_parameter_envp@l(11);
  84. lis 11,__stkptr@ha
  85. stw 1,__stkptr@l(11);
  86. lis 11, ___fpc_ret@ha
  87. stw 1, ___fpc_ret@l(11)
  88. lis 11, __stkptr@ha
  89. stw 1, __stkptr@l(11)
  90. bl PASCALMAIN
  91. .globl _haltproc
  92. .type _haltproc, @function
  93. _haltproc:
  94. lis 11, ___fpc_ret@ha
  95. lwz 1, ___fpc_ret@l(11)
  96. addi 1, 1, 16
  97. lwz 0, 0(1)
  98. mtlr 0
  99. blr
  100. # li 0, 1 /* exit call */
  101. # lis 3, operatingsystem_result@h
  102. # stw 3, operatingsystem_result@l(3)
  103. # sc
  104. # b _haltproc
  105. /* Define a symbol for the first piece of initialized data. */
  106. .section ".data"
  107. .globl __data_start
  108. __data_start:
  109. data_start:
  110. ___fpc_ret: /* return address to libc */
  111. .long 0
  112. .section ".bss"
  113. .type __stkptr, @object
  114. .size __stkptr, 8
  115. .global __stkptr
  116. __stkptr:
  117. .skip 4
  118. .type operatingsystem_parameters, @object
  119. .size operatingsystem_parameters, 12
  120. operatingsystem_parameters:
  121. .skip 3 * 4
  122. .global operatingsystem_parameter_argc
  123. .global operatingsystem_parameter_argv
  124. .global operatingsystem_parameter_envp
  125. .set operatingsystem_parameter_argc, operatingsystem_parameters+0
  126. .set operatingsystem_parameter_argv, operatingsystem_parameters+4
  127. .set operatingsystem_parameter_envp, operatingsystem_parameters+8
  128. .section .note.GNU-stack,"",%progbits