cprt21.as 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 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 %esi
  25. movl %eax,%edi
  26. movl %esp,%ebx /* Points to the arguments */
  27. movl %esi,%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 %esi,U_SYSLINUX_ARGC /* Move the argument counter */
  34. movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */
  35. xorl %ebp,%ebp
  36. pushl %edi
  37. pushl %esp
  38. pushl %edx
  39. pushl $_fini
  40. pushl $_init
  41. pushl %ebx
  42. pushl %esi
  43. pushl $main
  44. call __libc_start_main
  45. hlt
  46. /* fake main routine which will be run from libc */
  47. main:
  48. /* save return address */
  49. popl %eax
  50. movl %eax,___fpc_ret
  51. movl %ebx,___fpc_ret_ebx
  52. pushl %eax
  53. /* start the program */
  54. call PASCALMAIN
  55. .globl _haltproc
  56. .type _haltproc,@function
  57. _haltproc:
  58. xorl %eax,%eax /* load and save exitcode */
  59. movw U_SYSLINUX_EXITCODE,%ax
  60. movl ___fpc_ret,%edx /* return to libc */
  61. movl ___fpc_ret_ebx,%ebx
  62. push %edx
  63. ret
  64. .data
  65. .align 4
  66. .globl ___fpc_brk_addr /* heap management */
  67. .type ___fpc_brk_addr,@object
  68. .size ___fpc_brk_addr,4
  69. ___fpc_brk_addr:
  70. .long 0
  71. ___fpc_ret: /* return address to libc */
  72. .long 0
  73. ___fpc_ret_ebx:
  74. .long 0
  75. #
  76. # $Log$
  77. # Revision 1.2 2000-01-07 16:32:28 daniel
  78. # * copyright 2000 added
  79. #
  80. # Revision 1.1 1999/05/03 21:29:36 peter
  81. # + glibc 2.1 support
  82. #
  83. # Revision 1.3 1998/11/04 10:16:25 peter
  84. # + xorl ebp,ebp to indicate end of backtrace
  85. #
  86. # Revision 1.2 1998/10/14 21:28:46 peter
  87. # * initialize fpu so sigfpe is finally generated for fpu errors
  88. #
  89. # Revision 1.1 1998/08/12 19:16:09 peter
  90. # + loader including libc init and exit
  91. #
  92. #