gprt21.as 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #
  2. # $Id$
  3. # This file is part of the Free Pascal run time library.
  4. # Copyright (c) 1998-2000 by Michael Van Canneyt and Peter Vreman
  5. # members of the Free Pascal development team.
  6. #
  7. # See the file COPYING.FPC, included in this distribution,
  8. # for details about the copyright.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY;without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. #
  14. #**********************************************************************}
  15. #
  16. # Linux ELF startup code for Free Pascal
  17. #
  18. .file "prt1.as"
  19. .text
  20. .globl _start
  21. .type _start,@function
  22. _start:
  23. /* First locate the start of the environment variables */
  24. popl %esi
  25. movl %eax,%edi
  26. movl %esp,%ebx /* Points to the arguments */
  27. movl %esi,%eax
  28. incl %eax
  29. shll $2,%eax
  30. addl %esp,%eax
  31. andl $0xfffffff8,%esp /* Align stack */
  32. movl %eax,U_SYSLINUX_ENVP /* Move the environment pointer */
  33. movl %esi,U_SYSLINUX_ARGC /* Move the argument counter */
  34. movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */
  35. movl %edi,%eax
  36. xorl %ebp,%ebp
  37. pushl %eax
  38. pushl %esp
  39. pushl %edx
  40. pushl $_fini
  41. pushl $_init
  42. pushl %ebx
  43. pushl %esi
  44. pushl $main
  45. call __libc_start_main
  46. hlt
  47. /* fake main routine which will be run from libc */
  48. .globl cmain
  49. .type cmain,@object
  50. cmain:
  51. /* save return address */
  52. popl %eax
  53. movl %eax,___fpc_ret
  54. movl %ebx,___fpc_ret_ebx
  55. movl %esi,___fpc_ret_esi
  56. movl %edi,___fpc_ret_edi
  57. pushl %eax
  58. /* start the program */
  59. call PASCALMAIN
  60. .globl _haltproc
  61. .type _haltproc,@function
  62. _haltproc:
  63. xorl %eax,%eax /* load and save exitcode */
  64. movw U_SYSLINUX_EXITCODE,%ax
  65. movl ___fpc_ret,%edx /* return to libc */
  66. movl ___fpc_ret_ebx,%ebx
  67. movl ___fpc_ret_esi,%esi
  68. movl ___fpc_ret_edi,%edi
  69. push %edx
  70. ret
  71. .globl __gmon_start__
  72. .type __gmon_start__,@object
  73. __gmon_start__:
  74. pushl %ebp
  75. movl __monstarted,%eax
  76. leal 0x1(%eax),%edx
  77. movl %esp,%ebp
  78. movl %edx,__monstarted
  79. testl %eax,%eax
  80. jnz .Lnomonstart
  81. pushl $etext /* Initialize gmon */
  82. pushl $_start
  83. call monstartup
  84. addl $8,%esp
  85. pushl $_mcleanup
  86. call atexit
  87. addl $4,%esp
  88. .Lnomonstart:
  89. movl %ebp,%esp
  90. popl %ebp
  91. ret
  92. .data
  93. .align 4
  94. .globl ___fpc_brk_addr /* heap management */
  95. .type ___fpc_brk_addr,@object
  96. .size ___fpc_brk_addr,4
  97. ___fpc_brk_addr:
  98. .long 0
  99. ___fpc_ret: /* return address to libc */
  100. .long 0
  101. ___fpc_ret_ebx:
  102. .long 0
  103. ___fpc_ret_esi:
  104. .long 0
  105. ___fpc_ret_edi:
  106. .long 0
  107. .bss
  108. .lcomm __monstarted,4
  109. #
  110. # $Log$
  111. # Revision 1.3 2000-01-07 16:32:28 daniel
  112. # * copyright 2000 added
  113. #
  114. # Revision 1.2 1999/05/03 23:30:29 peter
  115. # * small update
  116. # * uses gprt1 again for gprt21 becuase gprt21.as crashes
  117. #
  118. # Revision 1.1 1999/05/03 21:29:36 peter
  119. # + glibc 2.1 support
  120. #
  121. # Revision 1.3 1998/11/04 10:16:25 peter
  122. # + xorl ebp,ebp to indicate end of backtrace
  123. #
  124. # Revision 1.2 1998/10/14 21:28:46 peter
  125. # * initialize fpu so sigfpe is finally generated for fpu errors
  126. #
  127. # Revision 1.1 1998/08/12 19:16:09 peter
  128. # + loader including libc init and exit
  129. #
  130. #