gprt0.as 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 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,operatingsystem_parameter_envp /* Move the environment pointer */
  33. movl %ecx,operatingsystem_parameter_argc /* Move the argument counter */
  34. movl %ebx,operatingsystem_parameter_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. _haltproc2: # GAS <= 2.15 bug: generates larger jump if a label is exported
  51. movzwl operatingsystem_result,%ebx
  52. pushl %ebx
  53. call exit /* call libc exit, this will */
  54. /* write the gmon.out */
  55. xorl %eax,%eax
  56. incl %eax /* eax=1, exit call */
  57. popl %ebx
  58. int $0x80
  59. jmp _haltproc2
  60. .data
  61. ___fpucw:
  62. .long 0x1332
  63. .bss
  64. .type ___fpc_brk_addr,@object
  65. .comm ___fpc_brk_addr,4 /* heap management */
  66. .comm operatingsystem_parameter_envp,4
  67. .comm operatingsystem_parameter_argc,4
  68. .comm operatingsystem_parameter_argv,4
  69. #
  70. # $Log$
  71. # Revision 1.4 2004-07-03 21:50:31 daniel
  72. # * Modified bootstrap code so separate prt0.as/prt0_10.as files are no
  73. # longer necessary
  74. #
  75. # Revision 1.3 2002/09/07 16:01:20 peter
  76. # * old logs removed and tabs fixed
  77. #