dllprt0.as 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. /* Save initial stackpointer */
  26. ldr ip,=__stkptr
  27. str sp,[ip]
  28. /* Get environment info from libc */
  29. ldr ip,=environ
  30. ldr r0,[ip]
  31. /* Check if environment is NULL */
  32. cmp r0,#0
  33. ldreq r0,=EmptyEnv
  34. ldr ip,=operatingsystem_parameter_envp
  35. str r0,[ip]
  36. /* Register exit handler. It is called only when the main process terminates */
  37. ldr r0,=FPC_LIB_EXIT
  38. blx atexit
  39. /* call main and exit normally */
  40. blx PASCALMAIN
  41. ldmea fp, {fp, sp, pc}
  42. /* --------------------------------------------------------- */
  43. .globl _haltproc
  44. .type _haltproc,#function
  45. _haltproc:
  46. .globl _haltproc_eabi
  47. .type _haltproc_eabi,#function
  48. _haltproc_eabi:
  49. ldr r0,=operatingsystem_result
  50. ldr r0,[r0]
  51. /* Go to libc exit() */
  52. ldr ip,=exit
  53. bx ip
  54. /* --------------------------------------------------------- */
  55. .data
  56. .comm __stkptr,4
  57. .comm operatingsystem_parameter_envp,4
  58. operatingsystem_parameter_argc:
  59. .global operatingsystem_parameter_argc
  60. .long 1
  61. operatingsystem_parameter_argv:
  62. .global operatingsystem_parameter_argv
  63. .long EmptyCmdLine
  64. EmptyCmdLine:
  65. .long EmptyCmdStr
  66. EmptyCmdStr:
  67. .ascii "\0"
  68. EmptyEnv:
  69. .long 0
  70. .long 0
  71. .long 0
  72. /* --------------------------------------------------------- */
  73. .section .init_array, "aw"
  74. .long FPC_SHARED_LIB_START