cprt0.as 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. # FreeBSD 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. # "FreeBSD" field in the abitag to the relevant ABI number
  19. # Some versions of the "file" command support
  20. # visualizing this constant. If not use elfdump, or patch
  21. # automatically using the ../i386/identpatch.sh script
  22. #
  23. # some typical values:
  24. #
  25. # freebsd 5.4 504000
  26. # freebsd 6.3 (prerelease) : 603100
  27. # freebsd 7.0 700055
  28. # freebsd 8.0 800500 (-stable)
  29. # FreeBSD 9.0 900044
  30. .file "crt1.c"
  31. #APP
  32. .ident "FreePascal 2.6.x/2.7.x series dynlinked to libc"
  33. #NO_APP
  34. .section .note.tag,"a",@note
  35. .align 4
  36. .type abitag, @object
  37. .size abitag, 48
  38. abitag:
  39. .long 8
  40. .long 4
  41. .long 1
  42. .string "FreeBSD"
  43. .long 1201000
  44. .long 8
  45. .long 4
  46. .long 1
  47. .string "FreeBSD"
  48. .long 0
  49. .globl __progname
  50. .section .rodata
  51. .LC0:
  52. .string ""
  53. .data
  54. .align 8
  55. .type __progname, @object
  56. .size __progname, 8
  57. __progname:
  58. .quad .LC0
  59. .text
  60. .p2align 4,,15
  61. .globl _start
  62. .type _start, @function
  63. _start:
  64. .LFB5:
  65. pushq %rbp
  66. .LCFI0:
  67. movq %rsp, %rbp
  68. .LCFI1:
  69. subq $48, %rsp
  70. .LCFI2:
  71. movq %rdi, -40(%rbp)
  72. movq %rsi, -48(%rbp)
  73. movq -40(%rbp), %rax
  74. movq (%rax), %rax
  75. movl %eax, -28(%rbp)
  76. movl %eax, operatingsystem_parameter_argc(%rip)
  77. movq -40(%rbp), %rax
  78. addq $8, %rax
  79. movq %rax, -24(%rbp)
  80. movq %rax, operatingsystem_parameter_argv(%rip)
  81. movq -40(%rbp), %rdx
  82. addq $16, %rdx
  83. movl -28(%rbp), %eax
  84. cltq
  85. salq $3, %rax
  86. leaq (%rdx,%rax), %rax
  87. movq %rax, -16(%rbp)
  88. movq -16(%rbp), %rax
  89. movq %rax, operatingsystem_parameter_envp(%rip)
  90. movq %rax, environ(%rip)
  91. cmpl $0, -28(%rbp)
  92. jle .L2
  93. movq -24(%rbp), %rax
  94. movq (%rax), %rax
  95. testq %rax, %rax
  96. je .L2
  97. movq -24(%rbp), %rax
  98. movq (%rax), %rax
  99. movq %rax, __progname(%rip)
  100. movq __progname(%rip), %rax
  101. movq %rax, -8(%rbp)
  102. jmp .L5
  103. .L6:
  104. movq -8(%rbp), %rax
  105. movzbl (%rax), %eax
  106. cmpb $47, %al
  107. jne .L7
  108. movq -8(%rbp), %rax
  109. addq $1, %rax
  110. movq %rax, __progname(%rip)
  111. .L7:
  112. addq $1, -8(%rbp)
  113. .L5:
  114. movq -8(%rbp), %rax
  115. movzbl (%rax), %eax
  116. testb %al, %al
  117. jne .L6
  118. .L2:
  119. movl $_DYNAMIC, %eax
  120. testq %rax, %rax
  121. je .L9
  122. movq -48(%rbp), %rdi
  123. call atexit
  124. jmp .L11
  125. .L9:
  126. call _init_tls
  127. .L11:
  128. movl $_fini, %edi
  129. call atexit
  130. call _init
  131. # movq -16(%rbp), %rdx
  132. # movq -24(%rbp), %rsi
  133. # movl -28(%rbp), %edi
  134. xorq %rbp,%rbp
  135. call main
  136. movl %eax, %edi
  137. call exit
  138. .LFE5:
  139. .size _start, .-_start
  140. #APP
  141. .ident "$FreeBSD: src/lib/csu/amd64/crt1.c,v 1.15 2005/10/07 22:13:17 bde Exp $"
  142. #NO_APP
  143. .bss
  144. .type __stkptr,@object
  145. .size __stkptr,8
  146. .global __stkptr
  147. __stkptr:
  148. .skip 8
  149. .type operatingsystem_parameters,@object
  150. .size operatingsystem_parameters,24
  151. operatingsystem_parameters:
  152. .skip 3*8
  153. .global operatingsystem_parameter_envp
  154. .global operatingsystem_parameter_argc
  155. .global operatingsystem_parameter_argv
  156. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  157. .set operatingsystem_parameter_argc,operatingsystem_parameters+8
  158. .set operatingsystem_parameter_argv,operatingsystem_parameters+16
  159. .comm environ,8,8
  160. .weak _DYNAMIC
  161. .section .eh_frame,"a",@progbits
  162. .Lframe1:
  163. .long .LECIE1-.LSCIE1
  164. .LSCIE1:
  165. .long 0x0
  166. .byte 0x1
  167. .string "zR"
  168. .uleb128 0x1
  169. .sleb128 -8
  170. .byte 0x10
  171. .uleb128 0x1
  172. .byte 0x3
  173. .byte 0xc
  174. .uleb128 0x7
  175. .uleb128 0x8
  176. .byte 0x90
  177. .uleb128 0x1
  178. .align 8
  179. .LECIE1:
  180. .LSFDE1:
  181. .long .LEFDE1-.LASFDE1
  182. .LASFDE1:
  183. .long .LASFDE1-.Lframe1
  184. .long .LFB5
  185. .long .LFE5-.LFB5
  186. .uleb128 0x0
  187. .byte 0x4
  188. .long .LCFI0-.LFB5
  189. .byte 0xe
  190. .uleb128 0x10
  191. .byte 0x86
  192. .uleb128 0x2
  193. .byte 0x4
  194. .long .LCFI1-.LCFI0
  195. .byte 0xd
  196. .uleb128 0x6
  197. .align 8
  198. .LEFDE1:
  199. .ident "GCC: (GNU) 4.2.1 20070719 [FreeBSD]"