dllprt0.as 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. /* Call main */
  45. blx PASCALMAIN
  46. /* Call library init */
  47. blx FPC_LIB_INIT_ANDROID
  48. ldmea fp, {fp, sp, pc}
  49. .L_GOT1:
  50. .long _GLOBAL_OFFSET_TABLE_-.LPIC1-8
  51. .L__stkptr:
  52. .word __stkptr(GOT)
  53. .Lenviron:
  54. .word environ(GOT)
  55. .LEmptyEnv:
  56. .word EmptyEnv(GOT)
  57. .Loperatingsystem_parameter_envp:
  58. .word operatingsystem_parameter_envp(GOT)
  59. /* --------------------------------------------------------- */
  60. .globl _haltproc
  61. .type _haltproc,#function
  62. _haltproc:
  63. .globl _haltproc_eabi
  64. .type _haltproc_eabi,#function
  65. _haltproc_eabi:
  66. /* Simply call libc exit(). _haltproc has the same declaration as exit. */
  67. blx exit
  68. /* --------------------------------------------------------- */
  69. .data
  70. .comm __stkptr,4
  71. .comm operatingsystem_parameter_envp,4
  72. operatingsystem_parameter_argc:
  73. .global operatingsystem_parameter_argc
  74. .long 1
  75. operatingsystem_parameter_argv:
  76. .global operatingsystem_parameter_argv
  77. .long EmptyCmdLine
  78. EmptyCmdLine:
  79. .long EmptyCmdStr
  80. EmptyCmdStr:
  81. .ascii "\0"
  82. EmptyEnv:
  83. .long 0
  84. .long 0
  85. .long 0
  86. /* --------------------------------------------------------- */
  87. .section .init_array, "aw"
  88. .long FPC_SHARED_LIB_START