gprt0.as 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 with profiling support for Free Pascal
  17. # Note: Needs linking with -lgmon and -lc
  18. #
  19. .file "gprt1.as"
  20. .text
  21. .globl _start
  22. .type _start,@function
  23. _start:
  24. /* First locate the start of the environment variables */
  25. popl %ecx
  26. movl %esp,%ebx /* Points to the arguments */
  27. movl %ecx,%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 %ecx,U_SYSLINUX_ARGC /* Move the argument counter */
  34. movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */
  35. finit /* initialize fpu */
  36. fwait
  37. fldcw ___fpucw
  38. pushl $_etext /* Initialize gmon */
  39. pushl $_start
  40. call monstartup
  41. addl $8,%esp
  42. pushl $_mcleanup
  43. call atexit
  44. addl $4,%esp
  45. xorl %ebp,%ebp
  46. call PASCALMAIN
  47. .globl _haltproc
  48. .type _haltproc,@function
  49. _haltproc:
  50. xorl %ebx,%ebx /* load and save exitcode */
  51. movw U_SYSLINUX_EXITCODE,%bx
  52. pushl %ebx
  53. call exit /* call libc exit, this will */
  54. /* write the gmon.out */
  55. movl $1,%eax /* exit call */
  56. popl %ebx
  57. int $0x80
  58. jmp _haltproc
  59. .data
  60. .align 4
  61. ___fpucw:
  62. .long 0x1332
  63. .globl ___fpc_brk_addr /* heap management */
  64. .type ___fpc_brk_addr,@object
  65. .size ___fpc_brk_addr,4
  66. ___fpc_brk_addr:
  67. .long 0
  68. .globl __curbrk /* necessary for libc */
  69. .type __curbrk,@object
  70. .size __curbrk,4
  71. __curbrk:
  72. .long 0
  73. #
  74. # $Log$
  75. # Revision 1.7 2000-01-07 16:32:28 daniel
  76. # * copyright 2000 added
  77. #
  78. # Revision 1.6 1999/11/08 23:07:48 peter
  79. # * removed aout entries
  80. #
  81. # Revision 1.5 1998/11/04 10:16:27 peter
  82. # + xorl ebp,ebp to indicate end of backtrace
  83. #
  84. # Revision 1.4 1998/10/14 21:28:48 peter
  85. # * initialize fpu so sigfpe is finally generated for fpu errors
  86. #
  87. # Revision 1.3 1998/08/08 14:42:10 peter
  88. # * added missing ___fpc_sbrk and logs
  89. #
  90. #