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