cprt0.as 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. #
  2. # This file is part of the Free Pascal run time library.
  3. # Copyright (c) 1999-2000 by Marco van de Voort, Pierre Mueller
  4. # members of the Free Pascal development team.
  5. #
  6. # See the file COPYING.FPC, included in this distribution,
  7. # for details about the copyright.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY;without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. #
  13. #**********************************************************************}
  14. #
  15. # DragonFly ELF startup code for Free Pascal for dynamical linking to libc.
  16. #
  17. # To avoid needing a "COMPAT" system, patch the constant following the
  18. # "DragonFly" field in the abitag to the relevant ABI number
  19. .file "crt1.c"
  20. .section .note.ABI-tag,"a",@progbits
  21. .align 4
  22. .type abitag, @object
  23. .size abitag, 28
  24. abitag:
  25. .long 10
  26. .long 4
  27. .long 1
  28. .string "DragonFly"
  29. .align 4
  30. .long 400000
  31. .globl __progname
  32. .section .rodata
  33. .LC0:
  34. .string ""
  35. .data
  36. .align 8
  37. .type __progname, @object
  38. .size __progname, 8
  39. __progname:
  40. .quad .LC0
  41. .text
  42. .p2align 4,,15
  43. .globl _start
  44. .type _start, @function
  45. _start:
  46. .LFB5:
  47. pushq %rbp
  48. .LCFI0:
  49. movq %rsp, %rbp
  50. .LCFI1:
  51. subq $48, %rsp
  52. .LCFI2:
  53. movq %rdi, -40(%rbp)
  54. movq %rsi, -48(%rbp)
  55. movq -40(%rbp), %rax
  56. movq (%rax), %rax
  57. movl %eax, -28(%rbp)
  58. movl %eax, operatingsystem_parameter_argc(%rip)
  59. movq -40(%rbp), %rax
  60. addq $8, %rax
  61. movq %rax, -24(%rbp)
  62. movq %rax, operatingsystem_parameter_argv(%rip)
  63. movq -40(%rbp), %rdx
  64. addq $16, %rdx
  65. movl -28(%rbp), %eax
  66. cltq
  67. salq $3, %rax
  68. leaq (%rdx,%rax), %rax
  69. movq %rax, -16(%rbp)
  70. movq -16(%rbp), %rax
  71. movq %rax, operatingsystem_parameter_envp(%rip)
  72. movq %rax, environ(%rip)
  73. cmpl $0, -28(%rbp)
  74. jle .L2
  75. movq -24(%rbp), %rax
  76. movq (%rax), %rax
  77. testq %rax, %rax
  78. je .L2
  79. movq -24(%rbp), %rax
  80. movq (%rax), %rax
  81. movq %rax, __progname(%rip)
  82. movq __progname(%rip), %rax
  83. movq %rax, -8(%rbp)
  84. jmp .L5
  85. .L6:
  86. movq -8(%rbp), %rax
  87. movzbl (%rax), %eax
  88. cmpb $47, %al
  89. jne .L7
  90. movq -8(%rbp), %rax
  91. addq $1, %rax
  92. movq %rax, __progname(%rip)
  93. .L7:
  94. addq $1, -8(%rbp)
  95. .L5:
  96. movq -8(%rbp), %rax
  97. movzbl (%rax), %eax
  98. testb %al, %al
  99. jne .L6
  100. .L2:
  101. movl $_DYNAMIC, %eax
  102. testq %rax, %rax
  103. je .L9
  104. movq -48(%rbp), %rdi
  105. call atexit
  106. jmp .L11
  107. .L9:
  108. call _init_tls
  109. .L11:
  110. movl $_fini, %edi
  111. call atexit
  112. call _init
  113. # movq -16(%rbp), %rdx
  114. # movq -24(%rbp), %rsi
  115. # movl -28(%rbp), %edi
  116. xorq %rbp,%rbp
  117. call main
  118. movl %eax, %edi
  119. call exit
  120. .LFE5:
  121. .size _start, .-_start
  122. .weak __error
  123. .type __error, @function
  124. __error:
  125. .LFB9:
  126. pushq %rbp
  127. movq %rsp, %rbp
  128. movq %fs:0, %rdx
  129. movq errno@gottpoff(%rip), %rax
  130. addq %rdx, %rax
  131. popq %rbp
  132. ret
  133. .LFE9:
  134. .size __error, .-__error
  135. .bss
  136. .type __stkptr,@object
  137. .size __stkptr,8
  138. .global __stkptr
  139. __stkptr:
  140. .skip 8
  141. .type operatingsystem_parameters,@object
  142. .size operatingsystem_parameters,24
  143. operatingsystem_parameters:
  144. .skip 3*8
  145. .global operatingsystem_parameter_envp
  146. .global operatingsystem_parameter_argc
  147. .global operatingsystem_parameter_argv
  148. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  149. .set operatingsystem_parameter_argc,operatingsystem_parameters+8
  150. .set operatingsystem_parameter_argv,operatingsystem_parameters+16
  151. .comm environ,8,8
  152. .weak _DYNAMIC
  153. .section .eh_frame,"a",@progbits
  154. .Lframe1:
  155. .long .LECIE1-.LSCIE1
  156. .LSCIE1:
  157. .long 0x0
  158. .byte 0x1
  159. .string "zR"
  160. .uleb128 0x1
  161. .sleb128 -8
  162. .byte 0x10
  163. .uleb128 0x1
  164. .byte 0x3
  165. .byte 0xc
  166. .uleb128 0x7
  167. .uleb128 0x8
  168. .byte 0x90
  169. .uleb128 0x1
  170. .align 8
  171. .LECIE1:
  172. .LSFDE1:
  173. .long .LEFDE1-.LASFDE1
  174. .LASFDE1:
  175. .long .LASFDE1-.Lframe1
  176. .long .LFB5
  177. .long .LFE5-.LFB5
  178. .uleb128 0x0
  179. .byte 0x4
  180. .long .LCFI0-.LFB5
  181. .byte 0xe
  182. .uleb128 0x10
  183. .byte 0x86
  184. .uleb128 0x2
  185. .byte 0x4
  186. .long .LCFI1-.LCFI0
  187. .byte 0xd
  188. .uleb128 0x6
  189. .align 8
  190. .LEFDE1:
  191. .ident "[DragonFly]"