dllprt0.as 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #
  2. # This file is part of the Free Pascal run time library.
  3. # Copyright (c) 2013 by Yury Sidorov and other
  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. # Shared library startup code for Free Pascal. Android-i386 target.
  16. #
  17. .file "dllprt0.as"
  18. .text
  19. .globl FPC_SHARED_LIB_START
  20. .type FPC_SHARED_LIB_START,@function
  21. FPC_SHARED_LIB_START:
  22. pushl %ebp
  23. movl %esp,%ebp
  24. /* Align the stack to a 16 byte boundary */
  25. andl $~15, %esp
  26. /* Save initial stackpointer */
  27. movl %esp,__stkptr
  28. /* Get environment info from libc */
  29. movl environ,%eax
  30. /* Check if environment is NULL */
  31. test %eax,%eax
  32. jne env_ok
  33. leal EmptyEnv,%eax
  34. env_ok:
  35. movl %eax,operatingsystem_parameter_envp
  36. /* Register exit handler. It is called only when the main process terminates */
  37. leal FPC_LIB_EXIT,%eax
  38. pushl %eax
  39. call atexit
  40. addl $4,%esp
  41. /* call main and exit normally */
  42. call PASCALMAIN
  43. leave
  44. ret
  45. /* --------------------------------------------------------- */
  46. .globl _haltproc
  47. .type _haltproc,@function
  48. _haltproc:
  49. movzwl operatingsystem_result,%ebx
  50. pushl %ebx
  51. /* Call libc exit() */
  52. call exit
  53. /* --------------------------------------------------------- */
  54. .data
  55. .comm __stkptr,4
  56. .comm operatingsystem_parameter_envp,4
  57. operatingsystem_parameter_argc:
  58. .global operatingsystem_parameter_argc
  59. .long 1
  60. operatingsystem_parameter_argv:
  61. .global operatingsystem_parameter_argv
  62. .long EmptyCmdLine
  63. EmptyCmdLine:
  64. .long EmptyCmdStr
  65. EmptyCmdStr:
  66. .ascii "\0"
  67. EmptyEnv:
  68. .long 0
  69. .long 0
  70. .long 0
  71. /* --------------------------------------------------------- */
  72. .section .init_array, "aw"
  73. .long FPC_SHARED_LIB_START