2
0

gprt0.as 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. /* Define a symbol for the first piece of initialized data. */
  52. .data
  53. .globl __data_start
  54. __data_start:
  55. .long 0
  56. .weak data_start
  57. data_start = __data_start
  58. .bss
  59. .comm __stkptr,4
  60. .comm operatingsystem_parameter_envp,4
  61. .comm operatingsystem_parameter_argc,4
  62. .comm operatingsystem_parameter_argv,4
  63. .section ".comment"
  64. .byte 0
  65. .ascii "generated by FPC http://www.freepascal.org\0"
  66. /* We need this stuff to make gdb behave itself, otherwise
  67. gdb will chokes with SIGILL when trying to debug apps.
  68. */
  69. .section ".note.ABI-tag", "a"
  70. .align 4
  71. .long 1f - 0f
  72. .long 3f - 2f
  73. .long 1
  74. 0: .asciz "GNU"
  75. 1: .align 4
  76. 2: .long 0
  77. .long 2,0,0
  78. 3: .align 4