cprt0.as 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #
  2. # $Id$
  3. # This file is part of the Free Pascal run time library.
  4. # Copyright (c) 1999-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 %ecx
  25. movl %esp,%ebx /* Points to the arguments */
  26. movl %ecx,%eax
  27. incl %eax
  28. shll $2,%eax
  29. addl %esp,%eax
  30. andl $0xfffffff8,%esp /* Align stack */
  31. movl %eax,U_SYSLINUX_ENVP /* Move the environment pointer */
  32. movl %ecx,U_SYSLINUX_ARGC /* Move the argument counter */
  33. movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */
  34. movl %eax,__environ /* libc environ */
  35. pushl %eax
  36. pushl %ebx
  37. pushl %ecx
  38. call __libc_init /* init libc */
  39. movzwl __fpu_control,%eax
  40. pushl %eax
  41. call __setfpucw
  42. addl $4,%esp
  43. pushl $_fini
  44. call atexit
  45. addl $4,%esp
  46. call _init
  47. popl %eax
  48. popl %eax
  49. xorl %ebp,%ebp
  50. call PASCALMAIN /* start the program */
  51. .globl _haltproc
  52. .type _haltproc,@function
  53. _haltproc:
  54. xorl %ebx,%ebx /* load and save exitcode */
  55. movw U_SYSLINUX_EXITCODE,%bx
  56. pushl %ebx
  57. call exit /* call libc exit, this will */
  58. /* write the gmon.out */
  59. movl $1,%eax /* exit call */
  60. popl %ebx
  61. int $0x80
  62. jmp _haltproc
  63. .data
  64. .align 4
  65. .globl ___fpc_brk_addr /* heap management */
  66. .type ___fpc_brk_addr,@object
  67. .size ___fpc_brk_addr,4
  68. ___fpc_brk_addr:
  69. .long 0
  70. .globl __curbrk /* necessary for libc */
  71. .type __curbrk,@object
  72. .size __curbrk,4
  73. __curbrk:
  74. .long 0
  75. .globl __environ
  76. .type __environ,@object
  77. .size __environ,4
  78. __environ:
  79. .long 0
  80. #
  81. # $Log$
  82. # Revision 1.3 2000-01-07 16:41:42 daniel
  83. # * copyright 2000
  84. #
  85. # Revision 1.2 2000/01/07 16:32:28 daniel
  86. # * copyright 2000 added
  87. #
  88. # Revision 1.1 1999/11/08 23:07:48 peter
  89. # * removed aout entries
  90. #
  91. # Revision 1.3 1998/11/04 10:16:25 peter
  92. # + xorl ebp,ebp to indicate end of backtrace
  93. #
  94. # Revision 1.2 1998/10/14 21:28:46 peter
  95. # * initialize fpu so sigfpe is finally generated for fpu errors
  96. #
  97. # Revision 1.1 1998/08/12 19:16:09 peter
  98. # + loader including libc init and exit
  99. #
  100. #