prt0.as 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. .version "01.01"
  21. gcc2_compiled.:
  22. .section .rodata
  23. .LC0:
  24. .ascii "\0"
  25. .data
  26. .p2align 2
  27. .globl __progname
  28. .type __progname,@object
  29. .size __progname,4
  30. __progname:
  31. .long .LC0
  32. .align 4
  33. .type __fpucw,@object
  34. .size __fpucw,4
  35. .global __fpucw
  36. ___fpucw:
  37. .long 0x1332
  38. .globl ___fpc_brk_addr /* heap management */
  39. .type ___fpc_brk_addr,@object
  40. .size ___fpc_brk_addr,4
  41. ___fpc_brk_addr:
  42. .long 0
  43. .text
  44. .p2align 2
  45. .globl _start
  46. .type _start,@function
  47. _start:
  48. pushl %ebp
  49. movl %esp,%ebp
  50. pushl %edi
  51. pushl %esi
  52. pushl %ebx
  53. #APP
  54. movl %edx,%edx
  55. #NO_APP
  56. leal 8(%ebp),%edi
  57. movl %edi,operatingsystem_parameter_argv
  58. mov -4(%edi),%eax
  59. movl %eax,operatingsystem_parameter_argc
  60. movl 4(%ebp),%ebx
  61. leal 12(%ebp,%ebx,4),%esi
  62. movl %esi,operatingsystem_parameter_envp
  63. movl %esi,environ
  64. testl %ebx,%ebx
  65. jle .L2
  66. movl 8(%ebp),%eax
  67. testl %eax,%eax
  68. je .L2
  69. movl %eax,__progname
  70. cmpb $0,(%eax)
  71. je .L2
  72. .p2align 2,0x90
  73. .L6:
  74. cmpb $47,(%eax)
  75. jne .L5
  76. leal 1(%eax),%ecx
  77. movl %ecx,__progname
  78. .L5:
  79. incl %eax
  80. cmpb $0,(%eax)
  81. jne .L6
  82. .L2:
  83. .L9:
  84. # copied from linux
  85. finit /* initialize fpu */
  86. fwait
  87. fldcw ___fpucw
  88. xorl %ebp,%ebp
  89. call main
  90. pushl %eax
  91. jmp _haltproc
  92. .p2align 2,0x90
  93. .globl _haltproc
  94. .type _haltproc,@function
  95. _haltproc:
  96. mov $1,%eax
  97. movzwl operatingsystem_result,%ebx
  98. pushl %ebx
  99. call _actualsyscall
  100. addl $4,%esp
  101. jmp _haltproc
  102. _actualsyscall:
  103. int $0x80
  104. jb .LErrorcode
  105. xor %ebx,%ebx
  106. ret
  107. .LErrorcode:
  108. mov %eax,%ebx
  109. mov $-1,%eax
  110. ret
  111. .p2align 2,0x90
  112. .Lfe1:
  113. .size _start,.Lfe1-_start
  114. .comm environ,4,4
  115. .weak _DYNAMIC
  116. .ident "GCC: (GNU) 2.7.2.1"
  117. .bss
  118. .type __stkptr,@object
  119. .size __stkptr,4
  120. .global __stkptr
  121. __stkptr:
  122. .skip 4
  123. .type operatingsystem_parameters,@object
  124. .size operatingsystem_parameters,12
  125. operatingsystem_parameters:
  126. .skip 3*4
  127. .global operatingsystem_parameter_envp
  128. .global operatingsystem_parameter_argc
  129. .global operatingsystem_parameter_argv
  130. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  131. .set operatingsystem_parameter_argc,operatingsystem_parameters+4
  132. .set operatingsystem_parameter_argv,operatingsystem_parameters+8
  133. //.section .threadvar,"aw",@nobits
  134. .comm ___fpc_threadvar_offset,4