dllprt0.as 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. sw x1, -4(x2)
  24. sw x8, -8(x2)
  25. addi x8, x2, 0
  26. addi x2, x2, -8
  27. /* a1 contains argc, a2 contains argv and a3 contains envp */
  28. lui x15, %hi(operatingsystem_parameter_argc)
  29. addi x15,x15,%lo(operatingsystem_parameter_argc)
  30. sw a1, (x15)
  31. lui x15, %hi(operatingsystem_parameter_argv)
  32. addi x15,x15,%lo(operatingsystem_parameter_argv)
  33. sw a2, (x15)
  34. lui x15, %hi(operatingsystem_parameter_envp)
  35. addi x15,x15,%lo(operatingsystem_parameter_envp)
  36. sw a3, (x15)
  37. /* save initial stackpointer */
  38. lui x15, %hi(__stklen)
  39. addi x15,x15,%lo(__stklen)
  40. sw x2, (x15)
  41. /* call main and exit normally */
  42. jal x1, PASCALMAIN
  43. lw x8, -8(x8)
  44. lw x1, -4(x8)
  45. jalr x0, x1
  46. .globl _haltproc
  47. .type _haltproc,function
  48. _haltproc:
  49. /* reload exitcode */
  50. lui x10, %hi(operatingsystem_result)
  51. addi x10,x10,%lo(operatingsystem_result)
  52. addi x17, x0, 248
  53. scall
  54. jal x0, _haltproc
  55. .data
  56. .type operatingsystem_parameters,object
  57. .size operatingsystem_parameters,12
  58. operatingsystem_parameters:
  59. .skip 3*4
  60. .global operatingsystem_parameter_envp
  61. .global operatingsystem_parameter_argc
  62. .global operatingsystem_parameter_argv
  63. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  64. .set operatingsystem_parameter_argc,operatingsystem_parameters+4
  65. .set operatingsystem_parameter_argv,operatingsystem_parameters+8
  66. .bss
  67. .comm __stkptr,4