dllprt0.as 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. addi sp, sp, -16
  24. sd ra, 8(sp)
  25. sd x8, 0(sp)
  26. addi x8, sp, 16
  27. /* a0 contains argc, a1 contains argv and a2 contains envp */
  28. 1:auipc x8,%pcrel_hi(operatingsystem_parameter_argc)
  29. sw a0,%pcrel_lo(1b)(x8)
  30. 1:auipc x8,%pcrel_hi(operatingsystem_parameter_argv)
  31. sd a1,%pcrel_lo(1b)(x8)
  32. 1:auipc x8,%pcrel_hi(operatingsystem_parameter_envp)
  33. sd a2,%pcrel_lo(1b)(x8)
  34. /* save initial stackpointer */
  35. 1:auipc x8,%pcrel_hi(__stklen)
  36. sd sp,%pcrel_lo(1b)(x8)
  37. /* call main and exit normally */
  38. 1:auipc x8,%pcrel_hi(PASCALMAIN)
  39. jalr ra, x8, %pcrel_lo(1b)
  40. ld x8, 0(x8)
  41. ld ra, 8(x8)
  42. addi sp, sp, 16
  43. jalr x0, ra
  44. .globl _haltproc
  45. .type _haltproc,function
  46. _haltproc:
  47. 1:auipc x8,%pcrel_hi(operatingsystem_result)
  48. lbu x1,%pcrel_lo(1b)(x8)
  49. addi x17, x0, 94
  50. ecall
  51. jal x0, _haltproc
  52. .data
  53. .type operatingsystem_parameters,object
  54. .size operatingsystem_parameters, 24
  55. operatingsystem_parameters:
  56. .skip 3 * 8
  57. .global operatingsystem_parameter_argc
  58. .global operatingsystem_parameter_argv
  59. .global operatingsystem_parameter_envp
  60. .set operatingsystem_parameter_argc, operatingsystem_parameters+0
  61. .set operatingsystem_parameter_argv, operatingsystem_parameters+8
  62. .set operatingsystem_parameter_envp, operatingsystem_parameters+16
  63. .bss
  64. .comm __stkptr,8