crt0.S 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ;; Startup code compiant to the ELF CRIS ABI.
  2. ;;
  3. ;; Highly based on code from glibc.
  4. #include <sysdep.h>
  5. .syntax no_register_prefix
  6. .text
  7. .globl _start
  8. .type _start,@function
  9. #if defined L_crt0 || ! defined __UCLIBC_CTOR_DTOR__
  10. .type __uClibc_main,@function
  11. #else
  12. .weak _init
  13. .weak _fini
  14. .type __uClibc_start_main,@function
  15. #endif
  16. ;; Setup a dummy reference to main so that if an application is linking
  17. ;; when the main() function is in a static library we can be sure that
  18. ;; the main() actually gets linked in.
  19. .type main,@function
  20. _start:
  21. ;; Clear the frame pointer, to mark the outermost frame.
  22. moveq 0, r8
  23. move.d [sp],r11
  24. move.d sp,[sp]
  25. move.d sp,r12
  26. addq 4,r12
  27. push r9
  28. #ifdef __PIC__
  29. move.d pc,r0
  30. sub.d .:GOTOFF,r0
  31. move.d _init:PLTG,r13
  32. add.d r0,r13
  33. move.d _fini:PLTG,r9
  34. add.d r0,r9
  35. move.d main:PLTG,r10
  36. add.d r0,r10
  37. #else
  38. move.d _init,r13
  39. move.d _fini,r9
  40. move.d main,r10
  41. #endif
  42. push r9
  43. #if (defined L_crt1 || defined L_gcrt1) && defined __UCLIBC_CTOR_DTOR__
  44. PLTCALL(__uClibc_start_main)
  45. #else
  46. PLTCALL(__uClibc_main)
  47. #endif
  48. ;; Crash if 'exit' returns.
  49. test.d [6502]
  50. 0:
  51. ba 0b
  52. nop
  53. ;; Define a symbol for the first piece of initialized data.
  54. .data
  55. .globl __data_start
  56. __data_start:
  57. .long 0
  58. .weak data_start
  59. data_start = __data_start