dllprt0.as 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 ebx */
  27. pushl %ebx
  28. /* GOT init */
  29. call fpc_geteipasebx
  30. addl $_GLOBAL_OFFSET_TABLE_,%ebx
  31. /* Save initial stackpointer */
  32. movl __stkptr@GOT(%ebx),%eax
  33. movl %esp,(%eax)
  34. /* Get environment info from libc */
  35. movl environ@GOT(%ebx),%eax
  36. movl (%eax),%eax
  37. /* Check if environment is NULL */
  38. test %eax,%eax
  39. jne env_ok
  40. movl EmptyEnv@GOT(%ebx),%eax
  41. env_ok:
  42. movl operatingsystem_parameter_envp@GOT(%ebx),%edx
  43. movl %eax,(%edx)
  44. /* Restore ebx */
  45. popl %ebx
  46. /* Call main */
  47. call PASCALMAIN@PLT
  48. /* Call library init */
  49. call FPC_LIB_INIT_ANDROID@PLT
  50. leave
  51. ret
  52. /* --------------------------------------------------------- */
  53. .globl _haltproc
  54. .type _haltproc,@function
  55. _haltproc:
  56. /* GOT init */
  57. call fpc_geteipasebx
  58. addl $_GLOBAL_OFFSET_TABLE_,%ebx
  59. /* Jump to libc exit(). _haltproc has the same declaration as exit. */
  60. jmp exit@PLT
  61. /* --------------------------------------------------------- */
  62. .data
  63. .comm __stkptr,4
  64. .comm operatingsystem_parameter_envp,4
  65. operatingsystem_parameter_argc:
  66. .global operatingsystem_parameter_argc
  67. .long 1
  68. operatingsystem_parameter_argv:
  69. .global operatingsystem_parameter_argv
  70. .long EmptyCmdLine
  71. EmptyCmdLine:
  72. .long EmptyCmdStr
  73. EmptyCmdStr:
  74. .ascii "\0"
  75. EmptyEnv:
  76. .long 0
  77. .long 0
  78. .long 0
  79. /* --------------------------------------------------------- */
  80. .section .init_array, "aw"
  81. .long FPC_SHARED_LIB_START