dllprt0.as 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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-ARM 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. mov ip, sp
  23. stmfd sp!,{fp, ip, lr, pc}
  24. sub fp, ip, #4
  25. /* Get GOT */
  26. ldr r3,.L_GOT1
  27. .LPIC1:
  28. add r3,pc,r3
  29. /* Save initial stackpointer */
  30. ldr ip,.L__stkptr
  31. ldr ip,[r3, ip]
  32. str sp,[ip]
  33. /* Get environment info from libc */
  34. ldr ip,.Lenviron
  35. ldr ip,[r3, ip]
  36. ldr r0,[ip]
  37. /* Check if environment is NULL */
  38. cmp r0,#0
  39. ldreq r0,.LEmptyEnv
  40. ldreq r0,[r3, r0]
  41. ldr ip,.Loperatingsystem_parameter_envp
  42. ldr ip,[r3, ip]
  43. str r0,[ip]
  44. /* Register exit handler. It is called only when the main process terminates */
  45. ldr r0,.LFPC_LIB_EXIT
  46. ldr r0,[r3, r0]
  47. blx atexit
  48. /* call main and exit normally */
  49. blx PASCALMAIN
  50. ldmea fp, {fp, sp, pc}
  51. .L_GOT1:
  52. .long _GLOBAL_OFFSET_TABLE_-.LPIC1-8
  53. .L__stkptr:
  54. .word __stkptr(GOT)
  55. .Lenviron:
  56. .word environ(GOT)
  57. .LEmptyEnv:
  58. .word EmptyEnv(GOT)
  59. .Loperatingsystem_parameter_envp:
  60. .word operatingsystem_parameter_envp(GOT)
  61. .LFPC_LIB_EXIT:
  62. .word FPC_LIB_EXIT(GOT)
  63. /* --------------------------------------------------------- */
  64. .globl _haltproc
  65. .type _haltproc,#function
  66. _haltproc:
  67. .globl _haltproc_eabi
  68. .type _haltproc_eabi,#function
  69. _haltproc_eabi:
  70. ldr r0,.Loperatingsystem_result
  71. .LPIC10:
  72. add r0,pc,r0
  73. ldr r0,[r0]
  74. /* Call libc exit() */
  75. blx exit
  76. .Loperatingsystem_result:
  77. .long operatingsystem_result-.LPIC10-8
  78. /* --------------------------------------------------------- */
  79. .data
  80. .comm __stkptr,4
  81. .comm operatingsystem_parameter_envp,4
  82. operatingsystem_parameter_argc:
  83. .global operatingsystem_parameter_argc
  84. .long 1
  85. operatingsystem_parameter_argv:
  86. .global operatingsystem_parameter_argv
  87. .long EmptyCmdLine
  88. EmptyCmdLine:
  89. .long EmptyCmdStr
  90. EmptyCmdStr:
  91. .ascii "\0"
  92. EmptyEnv:
  93. .long 0
  94. .long 0
  95. .long 0
  96. /* --------------------------------------------------------- */
  97. .section .init_array, "aw"
  98. .long FPC_SHARED_LIB_START