gprt1.as 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #
  2. # $Id$
  3. # This file is part of the Free Pascal run time library.
  4. # Copyright (c) 1993,97 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. pushl $_etext /* Initialize gmon */
  36. pushl $_start
  37. call monstartup
  38. addl $8,%esp
  39. pushl $_mcleanup
  40. call atexit
  41. addl $4,%esp
  42. call PASCALMAIN
  43. .globl _haltproc
  44. .type _haltproc,@function
  45. _haltproc:
  46. xorl %ebx,%ebx /* load and save exitcode */
  47. movw U_SYSLINUX_EXITCODE,%bx
  48. pushl %ebx
  49. call exit /* call libc exit, this will */
  50. /* write the gmon.out */
  51. movl $1,%eax /* exit call */
  52. popl %ebx
  53. int $0x80
  54. jmp _haltproc
  55. .data
  56. .align 4
  57. .globl ___brk_addr /* heap management */
  58. .type ___brk_addr,@object
  59. .size ___brk_addr,4
  60. ___brk_addr:
  61. .long 0
  62. .globl __curbrk /* necessary for libc */
  63. .type __curbrk,@object
  64. .size __curbrk,4
  65. __curbrk:
  66. .long 0