Signed-off-by: Max Filippov <jcmvbkbc(a)gmail.com>
---
test/tls/tls-macros-xtensa.h | 78 +++++++++++++++++++++++++++++++++++-
1 file changed, 76 insertions(+), 2 deletions(-)
diff --git a/test/tls/tls-macros-xtensa.h b/test/tls/tls-macros-xtensa.h
index 90fc726f6f6b..6b2621c221cb 100644
--- a/test/tls/tls-macros-xtensa.h
+++ b/test/tls/tls-macros-xtensa.h
@@ -22,6 +22,78 @@
: "a8", "a9", "a10", "a11", "a12",
"a13", "a14", "a15"); \
__l; })
#elif defined(__XTENSA_CALL0_ABI__)
+#ifdef __FDPIC__
+#define TLS_GD(x) \
+ ({ int *__l; \
+ int __t; \
+ extern unsigned long _GLOBAL_OFFSET_TABLE_[]; \
+ __asm__ ("movi %[tmp], " #x "@GOTTLSDESC\n\t" \
+ ".reloc ., R_XTENSA_TLS_ARG, " #x "\n\t" \
+ "add a2, %[tmp], %[got]\n\t" \
+ ".reloc ., R_XTENSA_TLS_FUNCDESC, " #x "\n\t" \
+ "l32i %[tmp], a2, 0\n\t" \
+ "mov a12, a11\n\t" \
+ ".reloc ., R_XTENSA_TLS_GOT, " #x "\n\t" \
+ "l32i a11, %[tmp], 4\n\t" \
+ ".reloc ., R_XTENSA_TLS_FUNC, " #x "\n\t" \
+ "_l32i %[tmp], %[tmp], 0\n\t" \
+ ".reloc ., R_XTENSA_TLS_CALL, " #x "\n\t" \
+ "callx0 %[tmp]\n\t" \
+ "mov a11, a12\n\t" \
+ "mov %[res], a2\n\t" \
+ : [res] "=r" (__l), [tmp] "=&r" (__t) \
+ : [got] "r" (_GLOBAL_OFFSET_TABLE_) \
+ : "a0", "a2", "a3", "a4", "a5",
"a6", "a7", "a8", "a9", "a10",
"a12");\
+ __l; })
+
+#define TLS_LD(x) \
+ ({ int *__l; \
+ int __t; \
+ extern unsigned long _GLOBAL_OFFSET_TABLE_[]; \
+ __asm__ ("movi %[tmp], _TLS_MODULE_BASE_@GOTTLSDESC\n\t" \
+ ".reloc ., R_XTENSA_TLS_ARG, _TLS_MODULE_BASE_\n\t" \
+ "add a2, %[tmp], %[got]\n\t" \
+ ".reloc ., R_XTENSA_TLS_FUNCDESC, _TLS_MODULE_BASE_\n\t"\
+ "l32i %[tmp], a2, 0\n\t" \
+ "mov a12, a11\n\t" \
+ ".reloc ., R_XTENSA_TLS_GOT, _TLS_MODULE_BASE_\n\t" \
+ "l32i a11, %[tmp], 4\n\t" \
+ ".reloc ., R_XTENSA_TLS_FUNC, _TLS_MODULE_BASE_\n\t" \
+ "_l32i %[tmp], %[tmp], 0\n\t" \
+ ".reloc ., R_XTENSA_TLS_CALL, _TLS_MODULE_BASE_\n\t" \
+ "callx0 %[tmp]\n\t" \
+ "mov a11, a12\n\t" \
+ "movi %[res], " #x "@DTPOFF\n\t" \
+ "add %[res], %[res], a2\n\t" \
+ : [res] "=r" (__l), [tmp] "=&r" (__t) \
+ : [got] "r" (_GLOBAL_OFFSET_TABLE_) \
+ : "a0", "a2", "a3", "a4", "a5",
"a6", "a7", "a8", "a9", "a10",
"a12");\
+ __l; })
+
+#define TLS_IE(x) \
+ ({ int *__l; \
+ int __t; \
+ extern unsigned long _GLOBAL_OFFSET_TABLE_[]; \
+ __asm__ ("movi %[tmp], " #x "@GOTTPOFF\n\t" \
+ ".reloc ., R_XTENSA_TLS_TPOFF_PTR, " #x "\n\t" \
+ "add %[tmp], %[tmp], %[got]\n\t" \
+ ".reloc ., R_XTENSA_TLS_TPOFF_LOAD, " #x "\n\t" \
+ "l32i %[tmp], %[tmp], 0\n\t" \
+ "rur %[res], threadptr\n\t" \
+ "add %[res], %[res], %[tmp]\n\t" \
+ : [res] "=r" (__l), [tmp] "=&r" (__t) \
+ : [got] "r" (_GLOBAL_OFFSET_TABLE_)); \
+ __l; })
+
+#define TLS_LE(x) \
+ ({ int *__l; \
+ int __t; \
+ __asm__ ("rur %0, threadptr\n\t" \
+ "movi %1, " #x "@TPOFF\n\t" \
+ "add %0, %0, %1\n\t" \
+ : "=r" (__l), "=r" (__t) ); \
+ __l; })
+#else
#define TLS_GD(x) \
({ int *__l; \
__asm__ ("movi a0, " #x "@TLSFUNC\n\t" \
@@ -44,10 +116,12 @@
: \
: "a2", "a3", "a4", "a5", "a6",
"a7", "a8", "a9", "a10", "a11");\
__l; })
+#endif
#else
#error Unsupported Xtensa ABI
#endif
+#ifndef __FDPIC__
#define TLS_IE(x) TLS_LE(x)
#define TLS_LE(x) \
@@ -57,5 +131,5 @@
"movi %1, " #x "@TPOFF\n\t" \
"add %0, %0, %1\n\t" \
: "=r" (__l), "=r" (__t) ); \
- __l; }); \
-
+ __l; })
+#endif
--
2.39.2