prt0.as 3.5 KB

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