prt0.as 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #
  2. # $Id: prt0.as,v 1.4 2004/07/03 21:50:30 daniel Exp $
  3. # This file is part of the Free Pascal run time library.
  4. # Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
  5. # and Peter Vreman
  6. # members of the Free Pascal development team.
  7. #
  8. # See the file COPYING.FPC, included in this distribution,
  9. # for details about the copyright.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY;without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. #
  15. #**********************************************************************}
  16. #
  17. # FreeBSD standard (static) ELF startup code for Free Pascal
  18. #
  19. .file "prt1.as"
  20. gcc2_compiled.:
  21. .section .rodata
  22. .LC0:
  23. .ascii "\0"
  24. .data
  25. .p2align 2
  26. .globl __progname
  27. .type __progname,@object
  28. .size __progname,4
  29. __progname:
  30. .long .LC0
  31. .align 4
  32. .type __fpucw,@object
  33. .size __fpucw,4
  34. .global __fpucw
  35. ___fpucw:
  36. .long 0x1332
  37. .globl ___fpc_brk_addr /* heap management */
  38. .type ___fpc_brk_addr,@object
  39. .size ___fpc_brk_addr,4
  40. ___fpc_brk_addr:
  41. .long 0
  42. .text
  43. .p2align 2
  44. .globl _start
  45. .type _start,@function
  46. _start:
  47. pushl %ebp
  48. movl %esp,%ebp
  49. pushl %edi
  50. pushl %esi
  51. pushl %ebx
  52. #APP
  53. movl %edx,%edx
  54. #NO_APP
  55. leal 8(%ebp),%edi
  56. movl %edi,operatingsystem_parameter_argv
  57. mov -4(%edi),%eax
  58. movl %eax,operatingsystem_parameter_argc
  59. movl 4(%ebp),%ebx
  60. leal 12(%ebp,%ebx,4),%esi
  61. movl %esi,operatingsystem_parameter_envp
  62. movl %esi,environ
  63. testl %ebx,%ebx
  64. jle .L2
  65. movl 8(%ebp),%eax
  66. testl %eax,%eax
  67. je .L2
  68. movl %eax,__progname
  69. cmpb $0,(%eax)
  70. je .L2
  71. .p2align 2,0x90
  72. .L6:
  73. cmpb $47,(%eax)
  74. jne .L5
  75. leal 1(%eax),%ecx
  76. movl %ecx,__progname
  77. .L5:
  78. incl %eax
  79. cmpb $0,(%eax)
  80. jne .L6
  81. .L2:
  82. .L9:
  83. # copied from linux
  84. finit /* initialize fpu */
  85. fwait
  86. fldcw ___fpucw
  87. xorl %ebp,%ebp
  88. call main
  89. pushl %eax
  90. jmp _haltproc
  91. .p2align 2,0x90
  92. .globl _haltproc
  93. .type _haltproc,@function
  94. _haltproc:
  95. mov $1,%eax
  96. movzwl operatingsystem_result,%ebx
  97. pushl %ebx
  98. call _actualsyscall
  99. addl $4,%esp
  100. jmp _haltproc
  101. _actualsyscall:
  102. int $0x80
  103. jb .LErrorcode
  104. xor %ebx,%ebx
  105. ret
  106. .LErrorcode:
  107. mov %eax,%ebx
  108. mov $-1,%eax
  109. ret
  110. .p2align 2,0x90
  111. .Lfe1:
  112. .size _start,.Lfe1-_start
  113. .comm environ,4,4
  114. .weak _DYNAMIC
  115. .ident "GCC: (GNU) 2.7.2.1"
  116. .bss
  117. .type __stkptr,@object
  118. .size __stkptr,4
  119. .global __stkptr
  120. __stkptr:
  121. .skip 4
  122. .type operatingsystem_parameters,@object
  123. .size operatingsystem_parameters,12
  124. operatingsystem_parameters:
  125. .skip 3*4
  126. .global operatingsystem_parameter_envp
  127. .global operatingsystem_parameter_argc
  128. .global operatingsystem_parameter_argv
  129. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  130. .set operatingsystem_parameter_argc,operatingsystem_parameters+4
  131. .set operatingsystem_parameter_argv,operatingsystem_parameters+8
  132. //.section .threadvar,"aw",@nobits
  133. .comm ___fpc_threadvar_offset,4
  134. .section .note.GNU-stack,"",@progbits