dllprt0.as 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. Start-up code for Free Pascal Compiler in a shared library,
  3. not linking with C library.
  4. Written by Edmund Grimley Evans in 2015 and released into the public domain.
  5. */
  6. .text
  7. .align 2
  8. .globl _startlib
  9. .type _startlib,#function
  10. _startlib:
  11. .globl FPC_SHARED_LIB_START
  12. .type FPC_SHARED_LIB_START,#function
  13. FPC_SHARED_LIB_START:
  14. stp x29,x30,[sp,#-16]!
  15. /* Save argc, argv and envp */
  16. adrp x9,:got:operatingsystem_parameter_argc
  17. ldr x9,[x9,#:got_lo12:operatingsystem_parameter_argc]
  18. str x0,[x9]
  19. adrp x9,:got:operatingsystem_parameter_argv
  20. ldr x9,[x9,#:got_lo12:operatingsystem_parameter_argv]
  21. str x1,[x9]
  22. adrp x9,:got:operatingsystem_parameter_envp
  23. ldr x9,[x9,#:got_lo12:operatingsystem_parameter_envp]
  24. str x2,[x9]
  25. /* Save initial stackpointer */
  26. adrp x9,:got:__stkptr
  27. ldr x9,[x9,#:got_lo12:__stkptr]
  28. mov x10,sp
  29. str x10,[x9]
  30. /* Call main */
  31. bl PASCALMAIN
  32. /* Return */
  33. ldp x29,x30,[sp],#16
  34. ret
  35. .globl _haltproc
  36. .type _haltproc,#function
  37. _haltproc:
  38. adrp x0,:got:operatingsystem_result
  39. ldr x0,[x0,#:got_lo12:operatingsystem_result]
  40. ldr w0,[x0]
  41. mov w8,#94 // syscall_nr_exit_group
  42. svc #0
  43. b _haltproc
  44. /* Define a symbol for the first piece of initialized data. */
  45. .data
  46. .align 3
  47. .globl __data_start
  48. __data_start:
  49. .long 0
  50. .weak data_start
  51. data_start = __data_start
  52. .bss
  53. .align 3
  54. .comm __dl_fini,8
  55. .comm __stkptr,8
  56. .comm operatingsystem_parameter_envp,8
  57. .comm operatingsystem_parameter_argc,8
  58. .comm operatingsystem_parameter_argv,8
  59. .section .note.GNU-stack,"",%progbits