dllprt0.as 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #
  2. # This file is part of the Free Pascal run time library.
  3. # Copyright (c) 2001 by Peter Vreman
  4. #
  5. # See the file COPYING.FPC, included in this distribution,
  6. # for details about the copyright.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY;without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. #
  12. #**********************************************************************}
  13. #
  14. # Linux ELF shared library startup code for Free Pascal
  15. #
  16. .file "dllprt0.as"
  17. .text
  18. .globl _startlib
  19. .type _startlib,@function
  20. _startlib:
  21. .globl FPC_SHARED_LIB_START
  22. .type FPC_SHARED_LIB_START,@function
  23. FPC_SHARED_LIB_START:
  24. pushl %ebp
  25. movl %esp,%ebp
  26. movl 8(%ebp),%eax
  27. movl 12(%ebp),%ecx
  28. movl 16(%ebp),%edx
  29. movl %edx,operatingsystem_parameter_envp /* Move the environment pointer */
  30. movl %eax,operatingsystem_parameter_argc /* Move the argument counter */
  31. movl %ecx,operatingsystem_parameter_argv /* Move the argument pointer */
  32. movb $1,TC_SYSTEM_ISLIBRARY
  33. /* Save initial stackpointer */
  34. movl %esp,__stkptr
  35. call PASCALMAIN
  36. leave
  37. ret
  38. .globl _haltproc
  39. .type _haltproc,@function
  40. _haltproc:
  41. _haltproc2: # GAS <= 2.15 bug: generates larger jump if a label is exported
  42. .globl FPC_SHARED_LIB_EXIT
  43. .type FPC_SHARED_LIB_EXIT,@function
  44. FPC_SHARED_LIB_EXIT:
  45. call lib_exit
  46. xorl %eax,%eax
  47. incl %eax /* eax=1, exit call */
  48. movzwl operatingsystem_result,%ebx
  49. int $0x80
  50. jmp _haltproc2
  51. .bss
  52. .type __stkptr,@object
  53. .size __stkptr,4
  54. .global __stkptr
  55. __stkptr:
  56. .skip 4
  57. .type operatingsystem_parameters,@object
  58. .size operatingsystem_parameters,12
  59. operatingsystem_parameters:
  60. .skip 3*4
  61. .global operatingsystem_parameter_envp
  62. .global operatingsystem_parameter_argc
  63. .global operatingsystem_parameter_argv
  64. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  65. .set operatingsystem_parameter_argc,operatingsystem_parameters+4
  66. .set operatingsystem_parameter_argv,operatingsystem_parameters+8
  67. .section .note.GNU-stack,"",%progbits