cprt0.as 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. .section ".note.openbsd.ident", "a"
  2. .p2align 2
  3. .long 8
  4. .long 4
  5. .long 1
  6. .ascii "OpenBSD\0"
  7. .long 0
  8. .previous
  9. .file "crt0.c"
  10. gcc2_compiled.:
  11. .data
  12. .align 32
  13. .type rcsid , @object
  14. .size rcsid , 58
  15. rcsid:
  16. .string "$OpenBSD: crt0.c,v 1.11 2003/06/27 22:30:38 deraadt Exp $"
  17. .globl __progname
  18. .section .rodata
  19. .LC0:
  20. .string ""
  21. .data
  22. .align 4
  23. .type __progname , @object
  24. .size __progname , 4
  25. __progname:
  26. .long .LC0
  27. .global __progname_storage
  28. .type __progname_storage, @ object
  29. .size __progname_storage, 256
  30. .align 4
  31. ___fpucw:
  32. .long 0x1332
  33. .globl ___fpc_brk_addr /* heap management */
  34. .type ___fpc_brk_addr,@object
  35. .size ___fpc_brk_addr,4
  36. ___fpc_brk_addr:
  37. .long 0
  38. #APP
  39. .text
  40. .align 4
  41. .globl __start
  42. .globl _start
  43. _start:
  44. __start:
  45. pushl %ebx #ps_strings
  46. pushl %ecx # obj
  47. pushl %edx # cleanup
  48. movl 12(%esp),%eax
  49. leal 20(%esp,%eax,4),%ecx
  50. leal 16(%esp),%edx
  51. pushl %ecx
  52. pushl %edx
  53. pushl %eax
  54. call ___start
  55. #NO_APP
  56. .text
  57. .align 4
  58. .globl ___start
  59. .type ___start , @function
  60. ___start:
  61. pushl %ebp
  62. movl %esp,%ebp
  63. subl $16,%esp
  64. pushl %esi
  65. pushl %ebx
  66. call fpc_geteipasecx
  67. addl $_GLOBAL_OFFSET_TABLE_,%ecx
  68. movl %ecx,%edi
  69. movl 12(%ebp),%esi
  70. movl 16(%ebp),%eax
  71. movl environ@GOT(%edi),%ecx
  72. movl %eax,(%ecx)
  73. movl operatingsystem_parameter_envp@GOT(%edi),%ecx
  74. movl %eax,(%ecx)
  75. movl (%esi),%ebx
  76. testl %ebx,%ebx
  77. je .L3
  78. addl $-8,%esp
  79. pushl $47
  80. pushl %ebx
  81. call _strrchr
  82. movl __progname@GOT(%edi),%ecx
  83. movl %eax,(%ecx)
  84. addl $16,%esp
  85. testl %eax,%eax
  86. jne .L4
  87. movl %ebx,(%ecx)
  88. jmp .L5
  89. .p2align 4,,7
  90. .L4:
  91. incl %eax
  92. movl %eax,(%ecx)
  93. .L5:
  94. movl __progname_storage@GOT(%edi),%edx
  95. jmp .L12
  96. .p2align 4,,7
  97. .L9:
  98. movb (%eax),%al
  99. movb %al,(%edx)
  100. movl __progname@GOT(%edi),%ecx
  101. incl (%ecx)
  102. incl %edx
  103. .L12:
  104. movl __progname@GOT(%edi),%ecx
  105. movl (%ecx),%eax
  106. cmpb $0,(%eax)
  107. je .L7
  108. movl __progname_storage@GOT(%edi),%ecx
  109. addl $255,%ecx
  110. cmpl %ecx,%edx
  111. jb .L9
  112. .L7:
  113. movb $0,(%edx)
  114. pushl %eax
  115. movl __progname_storage@GOT(%edi),%eax
  116. movl __progname@GOT(%edi),%ecx
  117. movl %eax,(%ecx)
  118. popl %eax
  119. .L3:
  120. # call __init
  121. subl $16,%esp
  122. pushl %eax
  123. movl 8(%ebp),%eax
  124. movl operatingsystem_parameter_argc@GOT(%edi),%ecx
  125. movl %eax,(%ecx)
  126. movl operatingsystem_parameter_argv@GOT(%edi),%ecx
  127. movl %esi,(%ecx)
  128. popl %eax
  129. # pushl environ
  130. # pushl %esi
  131. # pushl 8(%ebp)
  132. movl ___fpucw@GOT(%edi),%ecx
  133. finit
  134. fwait
  135. fldcw (%ecx)
  136. xorl %ebp,%ebp
  137. call main
  138. pushl %eax
  139. call exit@PLT
  140. .p2align 2,0x90
  141. .globl _haltproc
  142. .type _haltproc,@function
  143. _haltproc:
  144. call fpc_geteipasebx
  145. addl $_GLOBAL_OFFSET_TABLE_,%ebx
  146. movl operatingsystem_result@GOT(%ebx),%ebx
  147. movzwl (%ebx),%ebx
  148. pushl %ebx
  149. mov $1,%eax
  150. call .Lactualsyscall
  151. addl $4,%esp
  152. jmp _haltproc
  153. .Lactualsyscall:
  154. int $0x80
  155. jb .LErrorcode
  156. xor %ebx,%ebx
  157. ret
  158. .LErrorcode:
  159. mov %eax,%ebx
  160. mov $-1,%eax
  161. ret
  162. .p2align 2,0x90
  163. .Lfe1:
  164. .size ___start , . - ___start
  165. .align 4
  166. .type _strrchr , @function
  167. _strrchr:
  168. pushl %ebp
  169. movl %esp,%ebp
  170. pushl %ebx
  171. movl 8(%ebp),%eax
  172. movb 12(%ebp),%bl
  173. xorl %ecx,%ecx
  174. .p2align 4,,7
  175. .L14:
  176. movb (%eax),%dl
  177. cmpb %bl,%dl
  178. jne .L17
  179. movl %eax,%ecx
  180. .L17:
  181. testb %dl,%dl
  182. je .L16
  183. incl %eax
  184. jmp .L14
  185. .p2align 4,,7
  186. .L16:
  187. movl %ecx,%eax
  188. popl %ebx
  189. leave
  190. ret
  191. .size _strrchr , . - _strrchr
  192. .comm environ,4,4
  193. .comm __progname_storage,256,32
  194. .comm operatingsystem_parameter_envp,4,4
  195. .comm operatingsystem_parameter_argc,4,4
  196. .comm operatingsystem_parameter_argv,4,4