gprt0.as 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. Start-up code for Free Pascal Compiler when linking with C library
  3. with profiling support.
  4. */
  5. .text
  6. .align 2
  7. .globl _start
  8. .type _start,#function
  9. _start:
  10. /* Initialise FP to zero */
  11. mov x29,#0
  12. /* Get argc, argv, envp */
  13. ldr x1,[x0]
  14. add x2,x0,#8
  15. add x11,x1,#1
  16. add x11,x2,x11,lsl #3
  17. /* Save argc, argv, envp, and initial stack pointer */
  18. adrp x10,:got:operatingsystem_parameter_argc
  19. ldr x10,[x10,#:got_lo12:operatingsystem_parameter_argc]
  20. str x1,[x10]
  21. adrp x10,:got:operatingsystem_parameter_argv
  22. ldr x10,[x10,#:got_lo12:operatingsystem_parameter_argv]
  23. str x2,[x10]
  24. adrp x10,:got:operatingsystem_parameter_envp
  25. ldr x10,[x10,#:got_lo12:operatingsystem_parameter_envp]
  26. str x3,[x10]
  27. /* save environ */
  28. adrp x10,environ
  29. ldr x10,[x10,:lo12:environ]
  30. cbnz x10,.LBB0_2
  31. ldr x10,=environ
  32. str x3,[x10]
  33. .LBB0_2:
  34. /* save __progname */
  35. ldr w8,=operatingsystem_parameter_argc
  36. cmp w8,#0
  37. cset w8,le
  38. tbnz w8,#0,.LBB0_9
  39. // %bb.1:
  40. adrp x8,operatingsystem_parameter_argv
  41. ldr x8,[x8,:lo12:operatingsystem_parameter_argv]
  42. cbz x8,.LBB0_9
  43. // %bb.2:
  44. ldr x2,[x2]
  45. adrp x9,__progname
  46. adrp x10,__progname
  47. add x10,x10,:lo12:__progname
  48. str x2,[x10]
  49. ldr x8,[x9,:lo12:__progname]
  50. adrp x9,s
  51. add x9,x9,:lo12:s
  52. str x8,[x9]
  53. .LBB0_3:
  54. adrp x8,s
  55. ldr x8,[x8,:lo12:s]
  56. ldrb w9,[x8]
  57. cbz w9,.LBB0_8
  58. // %bb.4:
  59. adrp x8,s
  60. ldr x8,[x8, :lo12:s]
  61. ldrb w9,[x8]
  62. cmp w9,#47
  63. b.ne .LBB0_6
  64. // %bb.5:
  65. adrp x8,s
  66. ldr x8,[x8,:lo12:s]
  67. add x8,x8,#1
  68. adrp x9,__progname
  69. add x9,x9,:lo12:__progname
  70. str x8,[x9]
  71. .LBB0_6:
  72. // %bb.7:
  73. adrp x8,s
  74. adrp x9,s
  75. add x9,x9,:lo12:s
  76. ldr x8,[x8,:lo12:s]
  77. add x8,x8,#1
  78. str x8,[x9]
  79. b .LBB0_3
  80. .LBB0_8:
  81. .LBB0_9:
  82. adrp x10,:got:__stkptr
  83. ldr x10,[x10,#:got_lo12:__stkptr]
  84. mov x6,sp
  85. str x6,[x10]
  86. bl main
  87. /* This should never happen */
  88. b abort
  89. .globl _init_dummy
  90. .type _init_dummy,#function
  91. _init_dummy:
  92. ret
  93. .globl _fini_dummy
  94. .type _fini_dummy,#function
  95. _fini_dummy:
  96. ret
  97. .globl main_stub
  98. .type main_stub,#function
  99. main_stub:
  100. stp x29,x30,[sp,#-16]!
  101. /* Save initial stackpointer */
  102. mov x0,sp
  103. adrp x1,:got:__stkptr
  104. ldr x1,[x1,#:got_lo12:__stkptr]
  105. str x0,[x1]
  106. /* Initialize gmon */
  107. adrp x0,:got:_start
  108. ldr x0,[x0,#:got_lo12:_start]
  109. adrp x1,:got:_etext
  110. ldr x1,[x1,#:got_lo12:_etext]
  111. bl __monstartup
  112. adrp x0,:got:_mcleanup
  113. ldr x0,[x0,#:got_lo12:_mcleanup]
  114. bl atexit
  115. /* Start the program */
  116. bl PASCALMAIN
  117. b abort
  118. .globl _haltproc
  119. .type _haltproc,#function
  120. _haltproc:
  121. /* Return to libc */
  122. adrp x1,:got:__stkptr
  123. ldr x1,[x1,#:got_lo12:__stkptr]
  124. ldr x1,[x1]
  125. mov sp,x1
  126. ldp x29,x30,[sp],#16
  127. ret
  128. /* Define a symbol for the first piece of initialized data. */
  129. .data
  130. .align 3
  131. .globl __data_start
  132. __data_start:
  133. .long 0
  134. .weak data_start
  135. data_start = __data_start
  136. .bss
  137. .align 3
  138. .comm __stkptr,8
  139. .comm operatingsystem_parameter_envp,8
  140. .comm operatingsystem_parameter_argc,8
  141. .comm operatingsystem_parameter_argv,8
  142. .comm environ,8,8
  143. s:
  144. .xword 0
  145. .size s, 8
  146. .section .note.GNU-stack,"",%progbits