tls-macros-sh.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #define TLS_LE(x) \
  2. ({ int *__l; void *__tp; \
  3. __asm__ ("stc gbr,%1\n\t" \
  4. "mov.l 1f,%0\n\t" \
  5. "bra 2f\n\t" \
  6. " add %1,%0\n\t" \
  7. ".align 2\n\t" \
  8. "1: .long " #x "@tpoff\n\t" \
  9. "2:" \
  10. : "=r" (__l), "=r" (__tp)); \
  11. __l; })
  12. #ifdef __PIC__
  13. # define TLS_IE(x) \
  14. ({ int *__l; void *__tp; \
  15. register void *__gp __asm__("r12"); \
  16. __asm__ ("mov.l 1f,r0\n\t" \
  17. "stc gbr,%1\n\t" \
  18. "mov.l @(r0,r12),%0\n\t" \
  19. "bra 2f\n\t" \
  20. " add %1,%0\n\t" \
  21. ".align 2\n\t" \
  22. "1: .long " #x "@gottpoff\n\t" \
  23. "2:" \
  24. : "=r" (__l), "=r" (__tp) : "r" (__gp) : "r0"); \
  25. __l; })
  26. #else
  27. # define TLS_IE(x) \
  28. ({ int *__l; void *__tp; \
  29. __asm__ ("mov.l r12,@-r15\n\t" \
  30. "mova 0f,r0\n\t" \
  31. "mov.l 0f,r12\n\t" \
  32. "add r0,r12\n\t" \
  33. "mov.l 1f,r0\n\t" \
  34. "stc gbr,%1\n\t" \
  35. "mov.l @(r0,r12),%0\n\t" \
  36. "bra 2f\n\t" \
  37. " add %1,%0\n\t" \
  38. ".align 2\n\t" \
  39. "1: .long " #x "@gottpoff\n\t" \
  40. "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
  41. "2: mov.l @r15+,r12" \
  42. : "=r" (__l), "=r" (__tp) : : "r0"); \
  43. __l; })
  44. #endif
  45. #ifdef __PIC__
  46. # define TLS_LD(x) \
  47. ({ int *__l; \
  48. register void *__gp __asm__("r12"); \
  49. __asm__ ("mov.l 1f,r4\n\t" \
  50. "mova 2f,r0\n\t" \
  51. "mov.l 2f,r1\n\t" \
  52. "add r0,r1\n\t" \
  53. "jsr @r1\n\t" \
  54. " add r12,r4\n\t" \
  55. "bra 4f\n\t" \
  56. " nop\n\t" \
  57. ".align 2\n\t" \
  58. "1: .long " #x "@tlsldm\n\t" \
  59. "2: .long __tls_get_addr@plt\n\t" \
  60. "4: mov.l 3f,%0\n\t" \
  61. "bra 5f\n\t" \
  62. " add r0,%0\n\t" \
  63. ".align 2\n\t" \
  64. "3: .long " #x "@dtpoff\n\t" \
  65. "5:" \
  66. : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
  67. "r6", "r7", "pr", "t"); \
  68. __l; })
  69. #else
  70. # define TLS_LD(x) \
  71. ({ int *__l; \
  72. __asm__ ("mov.l r12,@-r15\n\t" \
  73. "mova 0f,r0\n\t" \
  74. "mov.l 0f,r12\n\t" \
  75. "add r0,r12\n\t" \
  76. "mov.l 1f,r4\n\t" \
  77. "mova 2f,r0\n\t" \
  78. "mov.l 2f,r1\n\t" \
  79. "add r0,r1\n\t" \
  80. "jsr @r1\n\t" \
  81. " add r12,r4\n\t" \
  82. "bra 4f\n\t" \
  83. " nop\n\t" \
  84. ".align 2\n\t" \
  85. "1: .long " #x "@tlsldm\n\t" \
  86. "2: .long __tls_get_addr@plt\n\t" \
  87. "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
  88. "4: mov.l 3f,%0\n\t" \
  89. "bra 5f\n\t" \
  90. " add r0,%0\n\t" \
  91. ".align 2\n\t" \
  92. "3: .long " #x "@dtpoff\n\t" \
  93. "5: mov.l @r15+,r12" \
  94. : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
  95. "pr", "t"); \
  96. __l; })
  97. #endif
  98. #ifdef __PIC__
  99. # define TLS_GD(x) \
  100. ({ int *__l; \
  101. register void *__gp __asm__("r12"); \
  102. __asm__ ("mov.l 1f,r4\n\t" \
  103. "mova 2f,r0\n\t" \
  104. "mov.l 2f,r1\n\t" \
  105. "add r0,r1\n\t" \
  106. "jsr @r1\n\t" \
  107. " add r12,r4\n\t" \
  108. "bra 3f\n\t" \
  109. " mov r0,%0\n\t" \
  110. ".align 2\n\t" \
  111. "1: .long " #x "@tlsgd\n\t" \
  112. "2: .long __tls_get_addr@plt\n\t" \
  113. "3:" \
  114. : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
  115. "r6", "r7", "pr", "t"); \
  116. __l; })
  117. #else
  118. # define TLS_GD(x) \
  119. ({ int *__l; \
  120. __asm__ ("mov.l r12,@-r15\n\t" \
  121. "mova 0f,r0\n\t" \
  122. "mov.l 0f,r12\n\t" \
  123. "add r0,r12\n\t" \
  124. "mov.l 1f,r4\n\t" \
  125. "mova 2f,r0\n\t" \
  126. "mov.l 2f,r1\n\t" \
  127. "add r0,r1\n\t" \
  128. "jsr @r1\n\t" \
  129. " add r12,r4\n\t" \
  130. "bra 3f\n\t" \
  131. " mov r0,%0\n\t" \
  132. ".align 2\n\t" \
  133. "1: .long " #x "@tlsgd\n\t" \
  134. "2: .long __tls_get_addr@plt\n\t" \
  135. "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
  136. "3: mov.l @r15+,r12" \
  137. : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
  138. "pr", "t"); \
  139. __l; })
  140. #endif