dllprt0.as 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * This file is part of the Free Pascal run time library.
  3. * Copyright (c) 2011 by Thomas Schatzl,
  4. * member of the Free Pascal development team.
  5. *
  6. * Startup code for shared libraries, ARM version.
  7. *
  8. * See the file COPYING.FPC, included in this distribution,
  9. * for details about the copyright.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. */
  15. .file "dllprt0.as"
  16. .text
  17. .globl _startlib
  18. .type _startlib,#function
  19. _startlib:
  20. .globl FPC_SHARED_LIB_START
  21. .type FPC_SHARED_LIB_START,#function
  22. FPC_SHARED_LIB_START:
  23. mov ip, sp
  24. stmfd sp!,{fp, ip, lr, pc}
  25. sub fp, ip, #4
  26. /* a1 contains argc, a2 contains argv and a3 contains envp */
  27. ldr ip, =operatingsystem_parameter_argc
  28. str a1, [ip]
  29. ldr ip, =operatingsystem_parameter_argv
  30. str a2, [ip]
  31. ldr ip, =operatingsystem_parameter_envp
  32. str a3, [ip]
  33. /* save initial stackpointer */
  34. ldr ip, =__stklen
  35. str sp, [ip]
  36. /* call main and exit normally */
  37. bl PASCALMAIN
  38. ldmdb fp, {fp, sp, pc}
  39. .globl _haltproc
  40. .type _haltproc,#function
  41. _haltproc:
  42. /* reload exitcode */
  43. ldr r0,=operatingsystem_result
  44. ldr r0,[r0]
  45. swi 0x900001
  46. b _haltproc
  47. .globl _haltproc_eabi
  48. .type _haltproc_eabi,#function
  49. _haltproc_eabi:
  50. /* reload exitcode */
  51. ldr r0,=operatingsystem_result
  52. ldr r0,[r0]
  53. mov r7,#248
  54. swi 0x0
  55. b _haltproc_eabi
  56. .data
  57. .type operatingsystem_parameters,#object
  58. .size operatingsystem_parameters,12
  59. operatingsystem_parameters:
  60. .skip 3*4
  61. .global operatingsystem_parameter_envp
  62. .global operatingsystem_parameter_argc
  63. .global operatingsystem_parameter_argv
  64. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  65. .set operatingsystem_parameter_argc,operatingsystem_parameters+4
  66. .set operatingsystem_parameter_argv,operatingsystem_parameters+8
  67. .bss
  68. .comm __stkptr,4