prt0.as 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * This file is part of the Free Pascal run time library.
  3. * Copyright (c) 2011 by Thomas Schatzl,
  4. * member of the Free Pascal development team.
  5. *
  6. * Startup code for normal programs, PowerPC version.
  7. *
  8. * See the file COPYING.FPC, included in this distribution,
  9. * for details about the copyright.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. */
  15. /*
  16. * Main program entry point for dynamic executables.
  17. */
  18. .section ".text"
  19. .globl _dynamic_start
  20. _dynamic_start:
  21. lis 11,__dl_fini@ha
  22. stw 7,__dl_fini@l(11)
  23. b _start
  24. /*
  25. * Main program entry point for static executables.
  26. */
  27. .section ".text"
  28. .globl _start
  29. _start:
  30. mr 26,1
  31. /* Set up an initial stack frame, and clear the LR. */
  32. clrrwi 1,1,4
  33. li 0,0
  34. stwu 1,-16(1)
  35. mtlr 0
  36. stw 0,0(1)
  37. lwz 3,0(26) /* get argc */
  38. lis 11,operatingsystem_parameter_argc@ha
  39. stw 3,operatingsystem_parameter_argc@l(11);
  40. addi 4,26,4 /* get argv */
  41. lis 11,operatingsystem_parameter_argv@ha
  42. stw 4,operatingsystem_parameter_argv@l(11);
  43. addi 27,3,1 /* calculate argc + 1 into r27 */
  44. slwi 27,27,2 /* calculate (argc + 1) * sizeof(char *) into r27 */
  45. add 5,4,27 /* get address of env[0] */
  46. lis 11,operatingsystem_parameter_envp@ha
  47. stw 5,operatingsystem_parameter_envp@l(11);
  48. lis 11,__stkptr@ha
  49. stw 1,__stkptr@l(11);
  50. bl PASCALMAIN
  51. /* we should not reach here. Crash horribly */
  52. trap
  53. .globl _haltproc
  54. .type _haltproc,@function
  55. _haltproc:
  56. lis 11,__dl_fini@ha
  57. lwz 11,__dl_fini@l(11)
  58. cmpwi 11, 0
  59. beq .LNoDlFiniCall
  60. mtctr 11
  61. bctrl
  62. .LNoDlFiniCall:
  63. lis 11,operatingsystem_result@ha
  64. lwz 3,operatingsystem_result@l(11)
  65. li 0,234 /* exit group call */
  66. sc
  67. lis 11,operatingsystem_result@ha
  68. lwz 3,operatingsystem_result@l(11)
  69. li 0,1 /* exit call */
  70. sc
  71. /* we should not reach here. Crash horribly */
  72. trap
  73. /* Define a symbol for the first piece of initialized data. */
  74. .section ".data"
  75. .globl __data_start
  76. __data_start:
  77. data_start:
  78. .section ".bss"
  79. .type __dl_fini, @object
  80. .size __dl_fini, 4
  81. .global __dl_fini
  82. __dl_fini:
  83. .skip 4
  84. .type __stkptr, @object
  85. .size __stkptr, 4
  86. .global __stkptr
  87. __stkptr:
  88. .skip 4
  89. .type operatingsystem_parameters, @object
  90. .size operatingsystem_parameters, 12
  91. operatingsystem_parameters:
  92. .skip 3 * 4
  93. .global operatingsystem_parameter_argc
  94. .global operatingsystem_parameter_argv
  95. .global operatingsystem_parameter_envp
  96. .set operatingsystem_parameter_argc, operatingsystem_parameters+0
  97. .set operatingsystem_parameter_argv, operatingsystem_parameters+4
  98. .set operatingsystem_parameter_envp, operatingsystem_parameters+8
  99. .section .note.GNU-stack,"",%progbits