gprt0.as 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. /* Let the libc call main and exit with its return code. */
  42. bl PASCALMAIN
  43. .globl _haltproc
  44. .type _haltproc,#function
  45. _haltproc:
  46. /* r0 contains exitcode */
  47. swi 0x900001
  48. b _haltproc
  49. /* Define a symbol for the first piece of initialized data. */
  50. .data
  51. .globl __data_start
  52. __data_start:
  53. .long 0
  54. .weak data_start
  55. data_start = __data_start
  56. .bss
  57. .comm __stkptr,4
  58. .comm operatingsystem_parameter_envp,4
  59. .comm operatingsystem_parameter_argc,4
  60. .comm operatingsystem_parameter_argv,4
  61. .section ".comment"
  62. .byte 0
  63. .ascii "generated by FPC http://www.freepascal.org\0"
  64. /* We need this stuff to make gdb behave itself, otherwise
  65. gdb will chokes with SIGILL when trying to debug apps.
  66. */
  67. .section ".note.ABI-tag", "a"
  68. .align 4
  69. .long 1f - 0f
  70. .long 3f - 2f
  71. .long 1
  72. 0: .asciz "GNU"
  73. 1: .align 4
  74. 2: .long 0
  75. .long 2,0,0
  76. 3: .align 4