cprt0.as 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. .L9:
  107. call _init_tls
  108. call _rtld_call_init
  109. movl $_fini, %edi
  110. call atexit
  111. call _init
  112. # movq -16(%rbp), %rdx
  113. # movq -24(%rbp), %rsi
  114. # movl -28(%rbp), %edi
  115. xorq %rbp,%rbp
  116. call main
  117. movl %eax, %edi
  118. call exit
  119. .LFE5:
  120. .size _start, .-_start
  121. .weak __error
  122. .type __error, @function
  123. __error:
  124. .LFB9:
  125. pushq %rbp
  126. movq %rsp, %rbp
  127. movq %fs:0, %rdx
  128. movq errno@gottpoff(%rip), %rax
  129. addq %rdx, %rax
  130. popq %rbp
  131. ret
  132. .LFE9:
  133. .size __error, .-__error
  134. .bss
  135. .type __stkptr,@object
  136. .size __stkptr,8
  137. .global __stkptr
  138. __stkptr:
  139. .skip 8
  140. .type operatingsystem_parameters,@object
  141. .size operatingsystem_parameters,24
  142. operatingsystem_parameters:
  143. .skip 3*8
  144. .global operatingsystem_parameter_envp
  145. .global operatingsystem_parameter_argc
  146. .global operatingsystem_parameter_argv
  147. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  148. .set operatingsystem_parameter_argc,operatingsystem_parameters+8
  149. .set operatingsystem_parameter_argv,operatingsystem_parameters+16
  150. .comm environ,8,8
  151. .weak _DYNAMIC
  152. .section .eh_frame,"a",@progbits
  153. .Lframe1:
  154. .long .LECIE1-.LSCIE1
  155. .LSCIE1:
  156. .long 0x0
  157. .byte 0x1
  158. .string "zR"
  159. .uleb128 0x1
  160. .sleb128 -8
  161. .byte 0x10
  162. .uleb128 0x1
  163. .byte 0x3
  164. .byte 0xc
  165. .uleb128 0x7
  166. .uleb128 0x8
  167. .byte 0x90
  168. .uleb128 0x1
  169. .align 8
  170. .LECIE1:
  171. .LSFDE1:
  172. .long .LEFDE1-.LASFDE1
  173. .LASFDE1:
  174. .long .LASFDE1-.Lframe1
  175. .long .LFB5
  176. .long .LFE5-.LFB5
  177. .uleb128 0x0
  178. .byte 0x4
  179. .long .LCFI0-.LFB5
  180. .byte 0xe
  181. .uleb128 0x10
  182. .byte 0x86
  183. .uleb128 0x2
  184. .byte 0x4
  185. .long .LCFI1-.LCFI0
  186. .byte 0xd
  187. .uleb128 0x6
  188. .align 8
  189. .LEFDE1:
  190. .ident "[DragonFly]"