dllprt0.as 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. subl $8, %esp /* align back to 16 bytes if it was before the call */
  27. movl 8(%ebp),%eax
  28. movl 12(%ebp),%ecx
  29. movl 16(%ebp),%edx
  30. movl %edx,operatingsystem_parameter_envp /* Move the environment pointer */
  31. movl %eax,operatingsystem_parameter_argc /* Move the argument counter */
  32. movl %ecx,operatingsystem_parameter_argv /* Move the argument pointer */
  33. movb $1,operatingsystem_islibrary
  34. /* Save initial stackpointer */
  35. movl %esp,__stkptr
  36. call PASCALMAIN
  37. leave
  38. ret
  39. .globl _haltproc
  40. .type _haltproc,@function
  41. _haltproc:
  42. _haltproc2: # GAS <= 2.15 bug: generates larger jump if a label is exported
  43. subl $12, %esp /* align back to 16 bytes if it was before the call */
  44. call lib_exit
  45. xorl %eax,%eax
  46. incl %eax /* eax=1, exit call */
  47. movzwl operatingsystem_result,%ebx
  48. int $0x80
  49. jmp _haltproc2
  50. .bss
  51. .type __stkptr,@object
  52. .size __stkptr,4
  53. .global __stkptr
  54. __stkptr:
  55. .skip 4
  56. .type operatingsystem_parameters,@object
  57. .size operatingsystem_parameters,12
  58. operatingsystem_parameters:
  59. .skip 3*4
  60. .global operatingsystem_parameter_envp
  61. .global operatingsystem_parameter_argc
  62. .global operatingsystem_parameter_argv
  63. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  64. .set operatingsystem_parameter_argc,operatingsystem_parameters+4
  65. .set operatingsystem_parameter_argv,operatingsystem_parameters+8
  66. .section .note.GNU-stack,"",%progbits