cprt0.as 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. .globl main_stub
  54. .type main_stub, @function
  55. main_stub:
  56. /* save link register and setup stack frame */
  57. mflr 0
  58. stw 0, 0(1)
  59. stwu 1, -16(1)
  60. lis 11, operatingsystem_parameter_argc@ha
  61. stw 3, operatingsystem_parameter_argc@l(11);
  62. lis 11, operatingsystem_parameter_argv@ha
  63. stw 4, operatingsystem_parameter_argv@l(11);
  64. lis 11, operatingsystem_parameter_envp@ha
  65. stw 5, operatingsystem_parameter_envp@l(11);
  66. lis 11,__stkptr@ha
  67. stw 1,__stkptr@l(11);
  68. lis 11, ___fpc_ret@ha
  69. stw 1, ___fpc_ret@l(11)
  70. lis 11, __stkptr@ha
  71. stw 1, __stkptr@l(11)
  72. bl PASCALMAIN
  73. .globl _haltproc
  74. .type _haltproc, @function
  75. _haltproc:
  76. lis 11, ___fpc_ret@ha
  77. lwz 1, ___fpc_ret@l(11)
  78. addi 1, 1, 16
  79. lwz 0, 0(1)
  80. mtlr 0
  81. blr
  82. # li 0, 1 /* exit call */
  83. # lis 3, operatingsystem_result@h
  84. # stw 3, operatingsystem_result@l(3)
  85. # sc
  86. # b _haltproc
  87. /* Define a symbol for the first piece of initialized data. */
  88. .section ".data"
  89. .globl __data_start
  90. __data_start:
  91. data_start:
  92. ___fpc_ret: /* return address to libc */
  93. .long 0
  94. .section ".bss"
  95. .type __stkptr, @object
  96. .size __stkptr, 8
  97. .global __stkptr
  98. __stkptr:
  99. .skip 4
  100. .type operatingsystem_parameters, @object
  101. .size operatingsystem_parameters, 12
  102. operatingsystem_parameters:
  103. .skip 3 * 4
  104. .global operatingsystem_parameter_argc
  105. .global operatingsystem_parameter_argv
  106. .global operatingsystem_parameter_envp
  107. .set operatingsystem_parameter_argc, operatingsystem_parameters+0
  108. .set operatingsystem_parameter_argv, operatingsystem_parameters+4
  109. .set operatingsystem_parameter_envp, operatingsystem_parameters+8
  110. .section .note.GNU-stack,"",%progbits