gprt0.as 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #
  2. # This file is part of the Free Pascal run time library.
  3. # Copyright (c) 1999-2000 by Michael Van Canneyt and Peter Vreman
  4. # members of the Free Pascal development team.
  5. #
  6. # See the file COPYING.FPC, included in this distribution,
  7. # for details about the copyright.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY;without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. #
  13. #**********************************************************************}
  14. #
  15. # Linux ELF startup code with profiling support for Free Pascal
  16. # Note: Needs linking with -lgmon and -lc
  17. #
  18. .file "gprt1.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,operatingsystem_parameter_envp /* Move the environment pointer */
  32. movl %ecx,operatingsystem_parameter_argc /* Move the argument counter */
  33. movl %ebx,operatingsystem_parameter_argv /* Move the argument pointer */
  34. finit /* initialize fpu */
  35. fwait
  36. fldcw ___fpucw
  37. pushl $_etext /* Initialize gmon */
  38. pushl $_start
  39. call monstartup
  40. addl $8,%esp
  41. pushl $_mcleanup
  42. call atexit
  43. addl $4,%esp
  44. xorl %ebp,%ebp
  45. call PASCALMAIN
  46. .globl _haltproc
  47. .type _haltproc,@function
  48. _haltproc:
  49. _haltproc2: # GAS <= 2.15 bug: generates larger jump if a label is exported
  50. movzwl operatingsystem_result,%ebx
  51. pushl %ebx
  52. call exit /* call libc exit, this will */
  53. /* write the gmon.out */
  54. movl $252,%eax /* exit_group */
  55. popl %ebx
  56. int $0x80
  57. jmp _haltproc2
  58. .data
  59. ___fpucw:
  60. .long 0x1332
  61. .bss
  62. .type ___fpc_brk_addr,@object
  63. .comm ___fpc_brk_addr,4 /* heap management */
  64. .comm operatingsystem_parameter_envp,4
  65. .comm operatingsystem_parameter_argc,4
  66. .comm operatingsystem_parameter_argv,4