diff options
Diffstat (limited to 'test/tls')
| -rw-r--r-- | test/tls/Makefile.in | 6 | ||||
| -rw-r--r-- | test/tls/tls-macros-aarch64.h | 52 | ||||
| -rw-r--r-- | test/tls/tls-macros-arc.h | 14 | ||||
| -rw-r--r-- | test/tls/tls-macros-csky.h | 55 | ||||
| -rw-r--r-- | test/tls/tls-macros-nios2.h | 46 | ||||
| -rw-r--r-- | test/tls/tls-macros-or1k.h | 75 | ||||
| -rw-r--r-- | test/tls/tls-macros-powerpc.h | 2 | ||||
| -rw-r--r-- | test/tls/tls-macros-powerpc64.h | 43 | ||||
| -rw-r--r-- | test/tls/tls-macros-riscv.h | 41 | ||||
| -rw-r--r-- | test/tls/tls-macros-xtensa.h | 82 | ||||
| -rw-r--r-- | test/tls/tls-macros.h | 28 | ||||
| -rw-r--r-- | test/tls/tst-tls6.c | 25 | ||||
| -rw-r--r-- | test/tls/tst-tls7.c | 25 | ||||
| -rw-r--r-- | test/tls/tst-tls8.c | 95 | 
14 files changed, 429 insertions, 160 deletions
| diff --git a/test/tls/Makefile.in b/test/tls/Makefile.in index 6a6a50e..348fc1c 100644 --- a/test/tls/Makefile.in +++ b/test/tls/Makefile.in @@ -1,6 +1,12 @@  # uClibc-ng TLS tests  # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. +CFLAGS += -DUSE_TLS=1 -DHAVE___THREAD=1 -I. + +ifneq ($(ARCH),alpha) +CFLAGS += -DHAVE_TLS_MODEL_ATTRIBUTE=1 +endif +  TESTS := tst-tls1 tst-tls2 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7	\  	tst-tls8 tst-tls9 tst-tls10 tst-tls11 tst-tls12 tst-tls13	\  	tst-tls14 tst-tls15 tst-tls16 tst-tls17 tst-tls18 tst-tls-at-ctor \ diff --git a/test/tls/tls-macros-aarch64.h b/test/tls/tls-macros-aarch64.h new file mode 100644 index 0000000..41a1384 --- /dev/null +++ b/test/tls/tls-macros-aarch64.h @@ -0,0 +1,52 @@ +/* Copyright (C) 2009-2020 Free Software Foundation, Inc. + +   This file is part of the GNU C Library. + +   The GNU C Library is free software; you can redistribute it and/or +   modify it under the terms of the GNU Lesser General Public License as +   published by the Free Software Foundation; either version 2.1 of the +   License, or (at your option) any later version. + +   The GNU C Library is distributed in the hope that it will be useful, +   but WITHOUT ANY WARRANTY; without even the implied warranty of +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU +   Lesser General Public License for more details. + +   You should have received a copy of the GNU Lesser General Public +   License along with the GNU C Library; if not, see +   <https://www.gnu.org/licenses/>.  */ + +#define TLS_LD(x) TLS_GD(x) + +#define TLS_GD(x)                                       \ +  ({ register unsigned long __result asm ("x0");        \ +     asm ("adrp %0, :tlsgd:" #x "; "                    \ +          "add  %0, %0, #:tlsgd_lo12:" #x "; "          \ +          "bl   __tls_get_addr;"                        \ +          "nop"                                         \ +          : "=r" (__result)                             \ +          :                                             \ +          : "x1", "x2", "x3", "x4", "x5", "x6",         \ +            "x7", "x8", "x9", "x10", "x11", "x12",      \ +            "x13", "x14", "x15", "x16", "x17", "x18",   \ +            "x30", "memory", "cc");                     \ +     (int *) (__result); }) + +#define TLS_IE(x)                                       \ +  ({ register unsigned long __result asm ("x0");        \ +     register unsigned long __t;                        \ +     asm ("mrs  %1, tpidr_el0; "                        \ +          "adrp %0, :gottprel:" #x "; "                 \ +          "ldr  %0, [%0, #:gottprel_lo12:" #x "]; "     \ +          "add  %0, %0, %1"                             \ +          : "=r" (__result), "=r" (__t));               \ +     (int *) (__result); }) + +#define TLS_LE(x)                                       \ +  ({ register unsigned long __result asm ("x0");        \ +     asm ("mrs  %0, tpidr_el0; "                        \ +          "add  %0, %0, :tprel_hi12:" #x "; "           \ +          "add  %0, %0, :tprel_lo12_nc:" #x             \ +          : "=r" (__result));                           \ +     (int *) (__result); }) + diff --git a/test/tls/tls-macros-arc.h b/test/tls/tls-macros-arc.h index 4b2d6f8..2f621d5 100644 --- a/test/tls/tls-macros-arc.h +++ b/test/tls/tls-macros-arc.h @@ -2,14 +2,12 @@  #define TLS_LD(x)	TLS_IE(x)  #define TLS_GD(x)					\ -  ({ int *__result;					\ -     __asm__ ("add r0, pcl, @" #x "@tlsgd      \n"     	\ -	  ".tls_gd_ld " #x "`bl __tls_get_addr@plt \n"	\ -	  "mov %0, r0                    \n"		\ -	  : "=&r" (__result)				\ -	  ::"r0","r1","r2","r3","r4","r5","r6","r7",	\ -	    "r8","r9","r10","r11","r12");		\ -     __result; }) +  ({ void *__result;					\ +     extern void *__tls_get_addr (void *);      \ +     __asm__ ("add %0, pcl, @" #x "@tlsgd \n"     \ +        ".tls_gd_ld " #x " \n"    \ +      : "=r" (__result));		\ +     (int *)__tls_get_addr(__result); })  #define TLS_LE(x)					\    ({ int *__result;					\ diff --git a/test/tls/tls-macros-csky.h b/test/tls/tls-macros-csky.h new file mode 100644 index 0000000..b7656a1 --- /dev/null +++ b/test/tls/tls-macros-csky.h @@ -0,0 +1,55 @@ +/* Macros for accessing thread-local storage.  C-SKY ABIV2 version. +   Copyright (C) 2018-2020 Free Software Foundation, Inc. + +   The GNU C Library is free software; you can redistribute it and/or +   modify it under the terms of the GNU Lesser General Public +   License as published by the Free Software Foundation; either +   version 2.1 of the License, or (at your option) any later version. + +   The GNU C Library is distributed in the hope that it will be useful, +   but WITHOUT ANY WARRANTY; without even the implied warranty of +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU +   Lesser General Public License for more details. + +   You should have received a copy of the GNU Lesser General Public +   License along with the GNU C Library.  If not, see +   <https://www.gnu.org/licenses/>.  */ + +# define TLS_LE(x)					\ +  ({ int *__result;					\ +     __asm__ ("lrw %0, " #x "@TPOFF\n\t"		\ +	      "add %0, tls, %0"				\ +	      : "=&r" (__result));			\ +     __result; }) + +# define TLS_IE(x)					\ +  ({ int *__result;					\ +     __asm__ ("grs a1, 1f\n"				\ +	      "1:\tlrw %0, " #x "@GOTTPOFF\n\t"		\ +	      "ldr.w %0, (a1, %0 << 0)\n\t"		\ +	      "add %0, tls, %0"				\ +	      : "=&r" (__result): : "a1");		\ +     __result; }) + +# define TLS_LD(x)					\ +  ({ char *__result;					\ +     int __offset;					\ +     extern void *__tls_get_addr (void *);		\ +     __asm__ ("grs a1, 1f\n"				\ +	      "1:\tlrw %0, " #x "@TLSLDM32;\n\t"	\ +	      "add %0, a1, %0"				\ +	      : "=r" (__result) : : "a1");		\ +     __result = (char *)__tls_get_addr (__result);	\ +     __asm__ ("lrw %0, " #x "@TLSLDO32"			\ +	      : "=r" (__offset));			\ +     (int *) (__result + __offset); }) + +# define TLS_GD(x)					\ +  ({ int *__result;					\ +     extern void *__tls_get_addr (void *);		\ +     __asm__ ("grs a1, 1f\n"				\ +	      "1:\tlrw %0, " #x "@TLSGD32\n\t"		\ +	      "add %0, a1, %0"				\ +	      : "=r" (__result) : : "a1");		\ +     (int *)__tls_get_addr (__result); }) + diff --git a/test/tls/tls-macros-nios2.h b/test/tls/tls-macros-nios2.h new file mode 100644 index 0000000..7029530 --- /dev/null +++ b/test/tls/tls-macros-nios2.h @@ -0,0 +1,46 @@ +#define TLS_LE(x)					\ +  ({ int *__result;					\ +     asm ("addi %0, r23, %%tls_le(" #x ")"		\ +	  : "=r" (__result));		                \ +     __result; }) + +#define TLS_IE(x)					\ +  ({ int *__result;					\ +     int __tmp;                                         \ +     asm ("nextpc %0 ; "                                \ +          "1: movhi %1, %%hiadj(_gp_got - 1b) ; "	\ +          "addi %1, %1, %%lo(_gp_got - 1b) ; "		\ +          "add %0, %0, %1 ; "                           \ +          "ldw %1, %%tls_ie(" #x ")(%0) ; "        	\ +	  "add %1, r23, %1"              		\ +          : "=&r" (__tmp), "=&r" (__result));           \ +     __result; }) + +#define TLS_LD(x)					\ +  ({ char *__result;					\ +     char *__result2;                                   \ +     int *__result3;                                    \ +     int __tmp;                                         \ +     extern void *__tls_get_addr (void *);		\ +     asm ("nextpc %0 ; "                                \ +          "1: movhi %1, %%hiadj(_gp_got - 1b) ; "	\ +          "addi %1, %1, %%lo(_gp_got - 1b) ; "		\ +          "add %0, %0, %1 ; "                           \ +          "addi %0, %0, %%tls_ldm(" #x ")"              \ +          : "=r" (__result), "=r" (__tmp));             \ +     __result2 = (char *)__tls_get_addr (__result);	\ +     asm ("addi %0, %1, %%tls_ldo(" #x ")"              \ +	  : "=r" (__result3) : "r" (__result2));        \ +     __result3; }) + +#define TLS_GD(x)					\ +  ({ int *__result;					\ +     int __tmp;                                         \ +     extern void *__tls_get_addr (void *);		\ +     asm ("nextpc %0 ; "                                \ +          "1: movhi %1, %%hiadj(_gp_got - 1b) ; "	\ +          "addi %1, %1, %%lo(_gp_got - 1b) ; "		\ +          "add %0, %0, %1 ; "                           \ +          "addi %0, %0, %%tls_gd(" #x ")"		\ +	  : "=r" (__result), "=r" (__tmp));		\ +     (int *)__tls_get_addr (__result); }) diff --git a/test/tls/tls-macros-or1k.h b/test/tls/tls-macros-or1k.h new file mode 100644 index 0000000..dcf78d6 --- /dev/null +++ b/test/tls/tls-macros-or1k.h @@ -0,0 +1,75 @@ +/* Macros to support TLS testing, OpenRISC version. +   Copyright (C) 2019 Free Software Foundation, Inc. +   This file is part of the GNU C Library. +   The GNU C Library is free software; you can redistribute it and/or +   modify it under the terms of the GNU Lesser General Public +   License as published by the Free Software Foundation; either +   version 2.1 of the License, or (at your option) any later version. +   The GNU C Library is distributed in the hope that it will be useful, +   but WITHOUT ANY WARRANTY; without even the implied warranty of +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU +   Lesser General Public License for more details. +   You should have received a copy of the GNU Lesser General Public +   License along with the GNU C Library.  If not, see +   <http://www.gnu.org/licenses/>.  */ + +#define TLS_LOAD_GOT \ +  ({ register long lr __asm__ ("r9");					\ +     long got;								\ +     asm ("l.jal    0x8\n\t"						\ +	  " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n\t"		\ +	  "l.ori    %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n\t"	\ +	  "l.add    %0, %0, %1"						\ +	  : "=r" (got), "=r" (lr));					\ +     got; }) + +/* General Dynamic: +     l.movhi r17, tlsgdhi(symbol) +     l.ori   r17, r17, tlsgdlo(symbol) +     l.add   r17, r17, r16 +     l.or    r3, r17, r17 +     l.jal   plt(__tls_get_addr) +      l.nop  */ + +#define TLS_GD(x)					\ +  ({ void *__tlsgd;					\ +     extern void *__tls_get_addr (void *);          	\ +     asm ("l.movhi %0, tlsgdhi(" #x ")\n\t"		\ +	  "l.ori   %0, %0, tlsgdlo(" #x ")\n\t"		\ +	  : "=r" (__tlsgd));				\ +     (int *) __tls_get_addr (TLS_LOAD_GOT + __tlsgd); }) + +#define TLS_LD(x) TLS_GD(x) + +/* Initial Exec: +     l.movhi r17, gottpoffhi(symbol) +     l.add   r17, r17, r16 +     l.lwz   r17, gottpofflo(symbol)(r17) +     l.add   r17, r17, r10 +     l.lbs   r17, 0(r17)  */ + +#define TLS_IE(x)					\ +  ({ register long __tls __asm__ ("r10");		\ +     void *__tlsie;					\ +     asm ("l.movhi  %0, gottpoffhi(" #x ")\n\t"		\ +	  "l.add    %0, %0, %1\n\t"			\ +	  "l.lwz    %0, gottpofflo(" #x ")(%0)\n\t"	\ +	  "l.add    %0, %0, %2\n\t"			\ +	  : "=&r" (__tlsie) : "r" (TLS_LOAD_GOT),	\ +	    "r" (__tls) : "memory");			\ +     __tlsie; }) + +/* Local Exec: +     l.movhi r17, tpoffha(symbol) +     l.add   r17, r17, r10 +     l.addi  r17, r17, tpofflo(symbol) +     l.lbs   r17, 0(r17)  */ + +#define TLS_LE(x)					\ +  ({ register long __tls __asm__ ("r10");		\ +     void *__tlsle;					\ +     asm ("l.movhi  %0, tpoffha(" #x ")\n\t"		\ +	  "l.add    %0, %0, %1\n\t"			\ +	  "l.addi   %0, %0, tpofflo(" #x ")\n\t"	\ +	  : "=&r" (__tlsle) : "r" (__tls) : "memory");	\ +     __tlsle; }) diff --git a/test/tls/tls-macros-powerpc.h b/test/tls/tls-macros-powerpc.h index ef293bb..8a368fa 100644 --- a/test/tls/tls-macros-powerpc.h +++ b/test/tls/tls-macros-powerpc.h @@ -1,5 +1,5 @@  #define __TLS_CALL_CLOBBERS						\ -	"0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",	\ +	"0", "4", "5", "6", "7", "8", "9", "10", "11", "12",	\  	"lr", "ctr", "cr0", "cr1", "cr5", "cr6", "cr7"  /* PowerPC32 Local Exec TLS access.  */ diff --git a/test/tls/tls-macros-powerpc64.h b/test/tls/tls-macros-powerpc64.h new file mode 100644 index 0000000..6021664 --- /dev/null +++ b/test/tls/tls-macros-powerpc64.h @@ -0,0 +1,43 @@ +#define __TLS_CALL_CLOBBERS						\ +	"0", "4", "5", "6", "7", "8", "9", "10", "11", "12",	\ +	"lr", "ctr", "cr0", "cr1", "cr5", "cr6", "cr7" + +/* PowerPC64 Local Exec TLS access.  */ +#define TLS_LE(x)							      \ +  ({ int * __result;							      \ +     asm ("addis %0,13," #x "@tprel@ha\n\t"				      \ +	  "addi  %0,%0," #x "@tprel@l"					      \ +	  : "=b" (__result) );						      \ +     __result;								      \ +  }) +/* PowerPC64 Initial Exec TLS access.  */ +#define TLS_IE(x)							      \ +  ({ int * __result;							      \ +     asm ("ld  %0," #x "@got@tprel(2)\n\t"				      \ +	  "add %0,%0," #x "@tls"					      \ +	  : "=r" (__result) );						      \ +     __result;								      \ +  }) + +/* PowerPC64 Local Dynamic TLS access.  */ +#define TLS_LD(x)							      \ +  ({ int * __result;							      \ +     asm ("addi  3,2," #x "@got@tlsld\n\t"				      \ +	  "bl    __tls_get_addr\n\t"					      \ +	  "nop   \n\t"							      \ +	  "addis %0,3," #x "@dtprel@ha\n\t"				      \ +	  "addi  %0,%0," #x "@dtprel@l"					      \ +	  : "=b" (__result) :						      \ +	  : "3", __TLS_CALL_CLOBBERS);					      \ +     __result;								      \ +  }) +/* PowerPC64 General Dynamic TLS access.  */ +#define TLS_GD(x)							      \ +  ({ register int *__result __asm__ ("r3");				      \ +     asm ("addi  3,2," #x "@got@tlsgd\n\t"				      \ +	  "bl    __tls_get_addr\n\t"					      \ +	  "nop   "							      \ +	  : "=r" (__result) :						      \ +	  : __TLS_CALL_CLOBBERS);					      \ +     __result;								      \ +  }) diff --git a/test/tls/tls-macros-riscv.h b/test/tls/tls-macros-riscv.h new file mode 100644 index 0000000..b780b4f --- /dev/null +++ b/test/tls/tls-macros-riscv.h @@ -0,0 +1,41 @@ +/* Macros to support TLS testing in times of missing compiler support. +   Copyright (C) 2017-2020 Free Software Foundation, Inc. + +   The GNU C Library is free software; you can redistribute it and/or +   modify it under the terms of the GNU Lesser General Public +   License as published by the Free Software Foundation; either +   version 2.1 of the License, or (at your option) any later version. + +   The GNU C Library is distributed in the hope that it will be useful, +   but WITHOUT ANY WARRANTY; without even the implied warranty of +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU +   Lesser General Public License for more details. + +   You should have received a copy of the GNU Lesser General Public +   License along with the GNU C Library.  If not, see +   <https://www.gnu.org/licenses/>.  */ + +#define TLS_GD(x)                                       \ +        ({ void *__result;                              \ +	extern void *__tls_get_addr (void *);           \ +        asm ("la.tls.gd %0, " #x "\n\t"                 \ +             : "=r" (__result));                        \ +        __tls_get_addr (__result); }) + +#define TLS_LD(x) TLS_GD(x) + +#define TLS_IE(x)                                       \ +        ({ void *__result;                              \ +        asm ("la.tls.ie %0, " #x "\n\t"                 \ +             "add %0, %0, tp\n\t"                       \ +             : "=r" (__result));                        \ +        __result; }) + +#define TLS_LE(x)                                       \ +        ({ void *__result;                              \ +        asm ("lui %0, %%tprel_hi(" #x ")\n\t"           \ +             "add %0, %0, tp, %%tprel_add(" #x ")\n\t"  \ +             "addi %0, %0, %%tprel_lo(" #x ")\n\t"      \ +             : "=r" (__result));                        \ +        __result; }) + diff --git a/test/tls/tls-macros-xtensa.h b/test/tls/tls-macros-xtensa.h index 179dc5e..6b2621c 100644 --- a/test/tls/tls-macros-xtensa.h +++ b/test/tls/tls-macros-xtensa.h @@ -15,13 +15,85 @@       __asm__ ("movi  a8, _TLS_MODULE_BASE_@TLSFUNC\n\t"			\  	  "movi a10, _TLS_MODULE_BASE_@TLSARG\n\t"			\  	  "callx8.tls a8, _TLS_MODULE_BASE_@TLSCALL\n\t"		\ -	  "movi %0, " #x "@TPOFF\n\t"					\ +	  "movi %0, " #x "@DTPOFF\n\t"					\  	  "add %0, %0, a10\n\t"						\  	  : "=r" (__l)							\  	  :								\  	  : "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"				\ @@ -38,16 +110,18 @@       __asm__ ("movi  a0, _TLS_MODULE_BASE_@TLSFUNC\n\t"			\  	  "movi a2, _TLS_MODULE_BASE_@TLSARG\n\t"			\  	  "callx0.tls a0, _TLS_MODULE_BASE_@TLSCALL\n\t"		\ -	  "movi %0, " #x "@TPOFF\n\t"					\ +	  "movi %0, " #x "@DTPOFF\n\t"					\  	  "add %0, %0, a2\n\t"						\  	  : "=r" (__l)							\  	  :								\  	  : "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 diff --git a/test/tls/tls-macros.h b/test/tls/tls-macros.h index 9053d8d..a94c3d2 100644 --- a/test/tls/tls-macros.h +++ b/test/tls/tls-macros.h @@ -16,11 +16,15 @@  /* XXX Until we get compiler support we don't need declarations.  */  #define VAR_INT_DECL(x) +#ifdef __aarch64__ +#include <tls-macros-aarch64.h> +#endif +  #ifdef __alpha__  #include <tls-macros-alpha.h>  #endif -#ifdef __arc__ +#if defined(__arc__) || defined(__ARC64_ARCH32__)  #include <tls-macros-arc.h>  #endif @@ -32,6 +36,10 @@  #endif  #endif +#ifdef __csky__ +#include <tls-macros-csky.h> +#endif +  #ifdef __i386__  #include <tls-macros-i386.h>  #endif @@ -56,10 +64,22 @@  #include <tls-macros-mips.h>  #endif -#ifdef __powerpc__ +#ifdef __nios2__ +#include <tls-macros-nios2.h> +#endif + +#if defined(__powerpc__) && !defined(__powerpc64__)  #include <tls-macros-powerpc.h>  #endif +#if defined(__powerpc__) && defined(__powerpc64__) +#include <tls-macros-powerpc64.h> +#endif + +#ifdef __riscv +#include <tls-macros-riscv.h> +#endif +  #ifdef __sh__  #include <tls-macros-sh.h>  #endif @@ -76,6 +96,10 @@  #include <tls-macros-xtensa.h>  #endif +#ifdef __or1k__ +#include <tls-macros-or1k.h> +#endif +  #if !defined TLS_LE || !defined TLS_IE \        || !defined TLS_LD || !defined TLS_GD  # error "No support for this architecture so far." diff --git a/test/tls/tst-tls6.c b/test/tls/tst-tls6.c index 7cc8f6b..b9a5609 100644 --- a/test/tls/tst-tls6.c +++ b/test/tls/tst-tls6.c @@ -26,31 +26,6 @@ do_test (void)  	  exit (1);  	} -      /* Dirty test code here: we peek into a private data structure. -	 We make sure that the module gets assigned the same ID every -	 time.  The value of the first round is used.  */ -#ifdef __UCLIBC__ -      if (modid == -1) -	modid = ((struct dyn_elf *) h)->dyn->l_tls_modid; -      else if (((struct dyn_elf *)h)->dyn->l_tls_modid != (size_t) modid) -	{ -	  printf ("round %d: modid now %zu, initially %d\n", -		  i, -		  ((struct dyn_elf *)h)->dyn->l_tls_modid, -		  modid); -	  result = 1; -	} -#else -      if (modid == -1) -	modid = ((struct link_map *) h)->l_tls_modid; -      else if (((struct link_map *) h)->l_tls_modid != modid) -	{ -	  printf ("round %d: modid now %zd, initially %d\n", -		  i, ((struct link_map *) h)->l_tls_modid, modid); -	  result = 1; -	} -#endif -        foop = dlsym (h, "foo");        if (foop == NULL)  	{ diff --git a/test/tls/tst-tls7.c b/test/tls/tst-tls7.c index b8bb71d..b0a6d37 100644 --- a/test/tls/tst-tls7.c +++ b/test/tls/tst-tls7.c @@ -24,31 +24,6 @@ do_test (void)  	  exit (1);  	} -      /* Dirty test code here: we peek into a private data structure. -	 We make sure that the module gets assigned the same ID every -	 time.  The value of the first round is used.  */ -#ifdef __UCLIBC__ -      if (modid == -1) -	modid = ((struct dyn_elf *) h)->dyn->l_tls_modid; -      else if (((struct dyn_elf *)h)->dyn->l_tls_modid != (size_t) modid) -	{ -	  printf ("round %d: modid now %zu, initially %d\n", -		  i, -		  ((struct dyn_elf *)h)->dyn->l_tls_modid, -		  modid); -	  result = 1; -	} -#else -      if (modid == -1) -	modid = ((struct link_map *) h)->l_tls_modid; -      else if (((struct link_map *) h)->l_tls_modid != (size_t) modid) -	{ -	  printf ("round %d: modid now %zu, initially %d\n", -		  i, ((struct link_map *) h)->l_tls_modid, modid); -	  result = 1; -	} -#endif -        fp = dlsym (h, "in_dso2");        if (fp == NULL)  	{ diff --git a/test/tls/tst-tls8.c b/test/tls/tst-tls8.c index 4635304..a723cab 100644 --- a/test/tls/tst-tls8.c +++ b/test/tls/tst-tls8.c @@ -29,31 +29,6 @@ do_test (void)  	  exit (1);  	} -      /* Dirty test code here: we peek into a private data structure. -	 We make sure that the module gets assigned the same ID every -	 time.  The value of the first round is used.  */ -#ifdef __UCLIBC__ -      if (modid1 == (size_t) -1) -	modid1 = ((struct dyn_elf *) h1)->dyn->l_tls_modid; -      else if (((struct dyn_elf *)h1)->dyn->l_tls_modid != (size_t) modid1) -	{ -	  printf ("round %d: modid now %zd, initially %zd\n", -		  i, -		  ((struct dyn_elf *)h1)->dyn->l_tls_modid, -		  modid1); -	  result = 1; -	} -#else -      if (modid1 == (size_t) -1) -	modid1 = ((struct link_map *) h1)->l_tls_modid; -      else if (((struct link_map *) h1)->l_tls_modid != modid1) -	{ -	  printf ("round %d: modid now %zd, initially %zd\n", -		  i, ((struct link_map *) h1)->l_tls_modid, modid1); -	  result = 1; -	} -#endif -        fp1 = dlsym (h1, "in_dso2");        if (fp1 == NULL)  	{ @@ -72,32 +47,6 @@ do_test (void)  	  exit (1);  	} -      /* Dirty test code here: we peek into a private data structure. -	 We make sure that the module gets assigned the same ID every -	 time.  The value of the first round is used.  */ -#ifdef __UCLIBC__ -      if (modid2 == (size_t) -1) -	modid2 = ((struct dyn_elf *)h2)->dyn->l_tls_modid; -      else if (((struct dyn_elf *)h2)->dyn->l_tls_modid -        != (size_t) modid2) -	{ -	  printf ("round %d: modid now %zd, initially %zd\n", -		  i, -		  ((struct dyn_elf *)h2)->dyn->l_tls_modid, -		  modid2); -	  result = 1; -	} -#else -      if (modid2 == (size_t) -1) -	modid2 = ((struct link_map *) h2)->l_tls_modid; -      else if (((struct link_map *) h2)->l_tls_modid != modid2) -	{ -	  printf ("round %d: modid now %zd, initially %zd\n", -		  i, ((struct link_map *) h2)->l_tls_modid, modid2); -	  result = 1; -	} -#endif -        bazp = dlsym (h2, "baz");        if (bazp == NULL)  	{ @@ -127,28 +76,6 @@ do_test (void)  	  exit (1);  	} -      /* Dirty test code here: we peek into a private data structure. -	 We make sure that the module gets assigned the same ID every -	 time.  The value of the first round is used.  */ -#ifdef __UCLIBC__ -      if (((struct dyn_elf *)h1)->dyn->l_tls_modid -        != modid1) -	{ -	  printf ("round %d: modid now %zd, initially %zd\n", -		  i, -		  ((struct dyn_elf *)h1)->dyn->l_tls_modid, -		  modid1); -	  result = 1; -	} -#else -      if (((struct link_map *) h1)->l_tls_modid != modid1) -	{ -	  printf ("round %d: modid now %zd, initially %zd\n", -		  i, ((struct link_map *) h1)->l_tls_modid, modid1); -	  result = 1; -	} -#endif -        fp1 = dlsym (h1, "in_dso2");        if (fp1 == NULL)  	{ @@ -167,28 +94,6 @@ do_test (void)  	  exit (1);  	} -      /* Dirty test code here: we peek into a private data structure. -	 We make sure that the module gets assigned the same ID every -	 time.  The value of the first round is used.  */ -#ifdef __UCLIBC__ -      if (((struct dyn_elf *)h2)->dyn->l_tls_modid -        != modid2) -	{ -	  printf ("round %d: modid now %zd, initially %zd\n", -		  i, -		  ((struct dyn_elf *)h2)->dyn->l_tls_modid, -		  modid2); -	  result = 1; -	} -#else -      if (((struct link_map *) h2)->l_tls_modid != modid2) -	{ -	  printf ("round %d: modid now %zd, initially %zd\n", -		  i, ((struct link_map *) h2)->l_tls_modid, modid2); -	  result = 1; -	} -#endif -        bazp = dlsym (h2, "baz");        if (bazp == NULL)  	{ | 
