gprt0.as 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. At this entry point, most registers' values are unspecified, except:
  3. a1 Contains a function pointer to be registered with `atexit'.
  4. This is how the dynamic linker arranges to have DT_FINI
  5. functions called for shared libraries that have been loaded
  6. before this code runs.
  7. sp The stack contains the arguments and environment:
  8. 0(sp) argc
  9. 4(sp) argv[0]
  10. ...
  11. (4*argc)(sp) NULL
  12. (4*(argc+1))(sp) envp[0]
  13. ...
  14. NULL
  15. */
  16. .text
  17. .globl _start
  18. .type _start,#function
  19. _start:
  20. /* Clear the frame pointer since this is the outermost frame. */
  21. mov fp, #0
  22. ldmia sp!, {a2}
  23. /* Pop argc off the stack and save a pointer to argv */
  24. ldr ip,=operatingsystem_parameter_argc
  25. ldr a3,=operatingsystem_parameter_argv
  26. str a2,[ip]
  27. /* calc envp */
  28. add a2,a2,#1
  29. add a2,sp,a2,LSL #2
  30. ldr ip,=operatingsystem_parameter_envp
  31. str sp,[a3]
  32. str a2,[ip]
  33. ldr r1,=_etext /* Initialize gmon */
  34. ldr r0,=_start
  35. bl monstartup
  36. ldr r0,=_mcleanup
  37. bl atexit
  38. /* Save initial stackpointer */
  39. ldr ip,=__stkptr
  40. str sp,[ip]
  41. /* align sp again to 8 byte boundary, needed by eabi */
  42. sub sp,sp,#4
  43. /* Let the libc call main and exit with its return code. */
  44. bl PASCALMAIN
  45. .globl _haltproc
  46. .type _haltproc,#function
  47. _haltproc:
  48. /* r0 contains exitcode */
  49. swi 0x900001
  50. b _haltproc
  51. .globl _haltproc_eabi
  52. .type _haltproc_eabi,#function
  53. _haltproc_eabi:
  54. /* r0 contains exitcode */
  55. mov r7,#248
  56. swi 0x0
  57. b _haltproc_eabi
  58. /* Define a symbol for the first piece of initialized data. */
  59. .data
  60. .globl __data_start
  61. __data_start:
  62. .long 0
  63. .weak data_start
  64. data_start = __data_start
  65. .bss
  66. .comm __stkptr,4
  67. .comm operatingsystem_parameter_envp,4
  68. .comm operatingsystem_parameter_argc,4
  69. .comm operatingsystem_parameter_argv,4
  70. .section ".comment"
  71. .byte 0
  72. .ascii "generated by FPC http://www.freepascal.org\0"
  73. /* We need this stuff to make gdb behave itself, otherwise
  74. gdb will chokes with SIGILL when trying to debug apps.
  75. */
  76. .section ".note.ABI-tag", "a"
  77. .align 4
  78. .long 1f - 0f
  79. .long 3f - 2f
  80. .long 1
  81. 0: .asciz "GNU"
  82. 1: .align 4
  83. 2: .long 0
  84. .long 2,0,0
  85. 3: .align 4
  86. .section .note.GNU-stack,"",%progbits