1 /* Macros to support TLS testing in times of missing compiler support. */
3 #define COMMON_INT_DEF(x) \
4 asm (".tls_common " #x ",4,4")
5 /* XXX Until we get compiler support we don't need declarations. */
6 #define COMMON_INT_DECL(x)
8 /* XXX This definition will probably be machine specific, too. */
9 #define VAR_INT_DEF(x) \
10 asm (".section .tdata\n\t" \
14 ".size " #x ",4\n\t" \
16 /* XXX Until we get compiler support we don't need declarations. */
17 #define VAR_INT_DECL(x)
19 #include_next <tls-macros.h>
21 /* XXX Each architecture must have its own asm for now. */
25 asm ("movl %%gs:0,%0\n\t" \
26 "subl $" #x "@tpoff,%0" \
33 asm ("movl %%gs:0,%0\n\t" \
34 "subl " #x "@gottpoff(%%ebx),%0" \
42 "1:\tmovl (%%esp), %%ebx\n\t" \
45 "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
46 "movl %%gs:0,%0\n\t" \
47 "subl " #x "@gottpoff(%%ebx),%0" \
48 : "=r" (__l), "=&b" (__b)); \
54 ({ int *__l, __c, __d; \
55 asm ("leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
56 "call ___tls_get_addr@plt\n\t" \
57 "leal " #x "@dtpoff(%%eax), %%eax" \
58 : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
62 ({ int *__l, __b, __c, __d; \
65 "1:\tmovl (%%esp), %%ebx\n\t" \
68 "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
69 "leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
70 "call ___tls_get_addr@plt\n\t" \
71 "leal " #x "@dtpoff(%%eax), %%eax" \
72 : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \
78 ({ int *__l, __c, __d; \
79 asm ("leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
80 "call ___tls_get_addr@plt\n\t" \
82 : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
86 ({ int *__l, __b, __c, __d; \
89 "1:\tmovl (%%esp), %%ebx\n\t" \
92 "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
93 "leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
94 "call ___tls_get_addr@plt\n\t" \
96 : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \
100 #elif defined __x86_64__
104 asm ("movq %%fs:0,%0\n\t" \
105 "leaq " #x "@tpoff(%0), %0" \
111 asm ("movq %%fs:0,%0\n\t" \
112 "addq " #x "@gottpoff(%%rip),%0" \
117 ({ int *__l, __c, __d; \
118 asm ("leaq " #x "@tlsld(%%rip),%%rdi\n\t" \
119 "call __tls_get_addr@plt\n\t" \
120 "leaq " #x "@dtpoff(%%rax), %%rax" \
121 : "=a" (__l), "=&c" (__c), "=&d" (__d) \
122 : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
126 ({ int *__l, __c, __d; \
127 asm (".byte 0x66\n\t" \
128 "leaq " #x "@tlsgd(%%rip),%%rdi\n\t" \
131 "call __tls_get_addr@plt" \
132 : "=a" (__l), "=&c" (__c), "=&d" (__d) \
133 : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
139 ({ int *__l; void *__tp; \
140 asm ("stc gbr,%1\n\t" \
145 "1: .long " #x "@tpoff\n\t" \
147 : "=r" (__l), "=r" (__tp)); \
152 ({ int *__l; void *__tp; \
153 register void *__gp __asm__("r12"); \
154 asm ("mov.l 1f,r0\n\t" \
156 "mov.l @(r0,r12),%0\n\t" \
160 "1: .long " #x "@gottpoff\n\t" \
162 : "=r" (__l), "=r" (__tp) : "r" (__gp) : "r0"); \
166 ({ int *__l; void *__tp; \
167 asm ("mov.l r12,@-r15\n\t" \
173 "mov.l @(r0,r12),%0\n\t" \
177 "1: .long " #x "@gottpoff\n\t" \
178 "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
179 "2: mov.l @r15+,r12" \
180 : "=r" (__l), "=r" (__tp) : : "r0"); \
187 register void *__gp __asm__("r12"); \
188 asm ("mov.l 1f,r4\n\t" \
197 "1: .long " #x "@tlsldm\n\t" \
198 "2: .long __tls_get_addr@plt\n\t" \
199 "4: mov.l 3f,%0\n\t" \
203 "3: .long " #x "@dtpoff\n\t" \
205 : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
206 "r6", "r7", "pr", "t"); \
211 asm ("mov.l r12,@-r15\n\t" \
224 "1: .long " #x "@tlsldm\n\t" \
225 "2: .long __tls_get_addr@plt\n\t" \
226 "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
227 "4: mov.l 3f,%0\n\t" \
231 "3: .long " #x "@dtpoff\n\t" \
232 "5: mov.l @r15+,r12" \
233 : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
241 register void *__gp __asm__("r12"); \
242 asm ("mov.l 1f,r4\n\t" \
251 "1: .long " #x "@tlsgd\n\t" \
252 "2: .long __tls_get_addr@plt\n\t" \
254 : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
255 "r6", "r7", "pr", "t"); \
260 asm ("mov.l r12,@-r15\n\t" \
273 "1: .long " #x "@tlsgd\n\t" \
274 "2: .long __tls_get_addr@plt\n\t" \
275 "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
276 "3: mov.l @r15+,r12" \
277 : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
282 #elif defined __alpha__
284 register void *__gp __asm__("$29");
288 asm ("call_pal 158\n\tlda $0," #x "($0)\t\t!tprel" : "=v"(__l)); \
292 ({ char *__tp; unsigned long __o; \
293 asm ("call_pal 158\n\tldq %1," #x "($gp)\t\t!gottprel" \
294 : "=v"(__tp), "=r"(__o) : "r"(__gp)); \
295 (int *)(__tp + __o); })
298 ({ extern void *__tls_get_addr(void *); int *__l; void *__i; \
299 asm ("lda %0," #x "($gp)\t\t!tlsldm" : "=r" (__i) : "r"(__gp)); \
300 __i = __tls_get_addr(__i); \
301 asm ("lda %0, " #x "(%1)\t\t!dtprel" : "=r"(__l) : "r"(__i)); \
305 ({ extern void *__tls_get_addr(void *); void *__i; \
306 asm ("lda %0," #x "($gp)\t\t!tlsgd" : "=r" (__i) : "r"(__gp)); \
307 (int *) __tls_get_addr(__i); })
310 #elif defined __ia64__
314 asm ("mov r2=r13\n\t" \
316 "addl %0=@tprel(" #x "),r2\n\t" \
317 : "=r" (__l) : : "r2" ); __l; })
321 register long __gp asm ("gp"); \
323 "addl r16=@ltoff(@tprel(" #x ")),gp\n\t" \
325 "ld8 r17=[r16]\n\t" \
327 "add %0=r13,r17\n\t" \
329 : "=r" (__l) : "r" (__gp) : "r16", "r17" ); __l; })
331 # define __TLS_CALL_CLOBBERS \
332 "r2", "r3", "r8", "r9", "r10", "r11", "r14", "r15", "r16", "r17", \
333 "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", \
334 "r27", "r28", "r29", "r30", "r31", \
335 "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
336 "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
338 "out0", "out1", "out2", "out3", "out4", "out5", "out6", "out7"
342 register long __gp asm ("gp"); \
345 "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
346 "addl out1=@dtprel(" #x "),r0\n\t" \
348 "ld8 out0=[r16]\n\t" \
349 "br.call.sptk.many b0=__tls_get_addr" \
354 : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
359 register long __gp asm ("gp"); \
362 "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
363 "addl r17=@ltoff(@dtprel(" #x ")),gp\n\t" \
365 "ld8 out0=[r16]\n\t" \
366 "ld8 out1=[r17]\n\t" \
367 "br.call.sptk.many b0=__tls_get_addr" \
372 : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
375 #elif defined __sparc__ && !defined __arch64__
379 asm ("sethi %%tle_hix22(" #x "), %0" : "=r" (__l)); \
380 asm ("xor %1, %%tle_lox10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
381 asm ("add %%g7, %1, %0" : "=r" (__l) : "r" (__l)); \
385 # define TLS_LOAD_PIC \
386 ({ register long pc __asm__ ("%o7"); \
388 asm ("sethi %%hi(_GLOBAL_OFFSET_TABLE_-4), %1\n\t" \
390 "add %1, %%lo(_GLOBAL_OFFSET_TABLE_+4), %1\n\t" \
391 "add %1, %0, %1\n\t" \
392 : "=r" (pc), "=r" (got)); \
395 # define TLS_LOAD_PIC \
397 asm (".hidden _GLOBAL_OFFSET_TABLE_\n\t" \
398 "sethi %%hi(_GLOBAL_OFFSET_TABLE_), %0\n\t" \
399 "or %0, %%lo(_GLOBAL_OFFSET_TABLE_), %0" \
406 asm ("sethi %%tie_hi22(" #x "), %0" : "=r" (__l)); \
407 asm ("add %1, %%tie_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
408 asm ("ld [%1 + %2], %0, %%tie_ld(" #x ")" \
409 : "=r" (__l) : "r" (TLS_LOAD_PIC), "r" (__l)); \
410 asm ("add %%g7, %1, %0, %%tie_add(" #x ")" : "=r" (__l) : "r" (__l)); \
414 ({ int *__l; register void *__o0 asm ("%o0"); \
416 asm ("sethi %%tldm_hi22(" #x "), %0" : "=r" (__l)); \
417 asm ("add %1, %%tldm_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
418 asm ("add %1, %2, %0, %%tldm_add(" #x ")" \
419 : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
420 asm ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
422 : "=r" (__o0) : "0" (__o0) \
423 : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
425 asm ("sethi %%tldo_hix22(" #x "), %0" : "=r" (__o)); \
426 asm ("xor %1, %%tldo_lox10(" #x "), %0" : "=r" (__o) : "r" (__o)); \
427 asm ("add %1, %2, %0, %%tldo_add(" #x ")" : "=r" (__l) \
428 : "r" (__o0), "r" (__o)); \
432 ({ int *__l; register void *__o0 asm ("%o0"); \
433 asm ("sethi %%tgd_hi22(" #x "), %0" : "=r" (__l)); \
434 asm ("add %1, %%tgd_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
435 asm ("add %1, %2, %0, %%tgd_add(" #x ")" \
436 : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
437 asm ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
439 : "=r" (__o0) : "0" (__o0) \
440 : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
444 #elif defined __sparc__ && defined __arch64__
448 asm ("sethi %%tle_hix22(" #x "), %0" : "=r" (__l)); \
449 asm ("xor %1, %%tle_lox10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
450 asm ("add %%g7, %1, %0" : "=r" (__l) : "r" (__l)); \
454 # define TLS_LOAD_PIC \
456 asm ("sethi %%hi(_GLOBAL_OFFSET_TABLE_-4), %1\n\t" \
458 "add %1, %%lo(_GLOBAL_OFFSET_TABLE_+4), %1\n\t" \
459 "add %1, %0, %1\n\t" \
460 : "=r" (pc), "=r" (got)); \
463 # define TLS_LOAD_PIC \
465 asm (".hidden _GLOBAL_OFFSET_TABLE_\n\t" \
466 "sethi %%hi(_GLOBAL_OFFSET_TABLE_), %0\n\t" \
467 "or %0, %%lo(_GLOBAL_OFFSET_TABLE_), %0" \
474 asm ("sethi %%tie_hi22(" #x "), %0" : "=r" (__l)); \
475 asm ("add %1, %%tie_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
476 asm ("ldx [%1 + %2], %0, %%tie_ldx(" #x ")" \
477 : "=r" (__l) : "r" (TLS_LOAD_PIC), "r" (__l)); \
478 asm ("add %%g7, %1, %0, %%tie_add(" #x ")" : "=r" (__l) : "r" (__l)); \
482 ({ int *__l; register void *__o0 asm ("%o0"); \
484 asm ("sethi %%tldm_hi22(" #x "), %0" : "=r" (__l)); \
485 asm ("add %1, %%tldm_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
486 asm ("add %1, %2, %0, %%tldm_add(" #x ")" \
487 : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
488 asm ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
490 : "=r" (__o0) : "0" (__o0) \
491 : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
493 asm ("sethi %%tldo_hix22(" #x "), %0" : "=r" (__o)); \
494 asm ("xor %1, %%tldo_lox10(" #x "), %0" : "=r" (__o) : "r" (__o)); \
495 asm ("add %1, %2, %0, %%tldo_add(" #x ")" : "=r" (__l) \
496 : "r" (__o0), "r" (__o)); \
500 ({ int *__l; register void *__o0 asm ("%o0"); \
501 asm ("sethi %%tgd_hi22(" #x "), %0" : "=r" (__l)); \
502 asm ("add %1, %%tgd_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
503 asm ("add %1, %2, %0, %%tgd_add(" #x ")" \
504 : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
505 asm ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
507 : "=r" (__o0) : "0" (__o0) \
508 : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
512 #elif defined __s390x__
515 ({ unsigned long __offset; \
516 asm ("bras %0,1f\n" \
517 "0:\t.quad " #x "@ntpoff\n" \
519 : "=a" (__offset) : : "cc" ); \
520 (int *) (__builtin_thread_pointer() + __offset); })
524 ({ unsigned long __offset; \
525 asm ("bras %0,1f\n" \
526 "0:\t.quad " #x "@gotntpoff\n" \
527 "1:\tlg %0,0(%0)\n\t" \
528 "lg %0,0(%0,%%r12):tls_load:" #x \
529 : "=&a" (__offset) : : "cc" ); \
530 (int *) (__builtin_thread_pointer() + __offset); })
533 ({ unsigned long __offset; \
534 asm ("bras %0,1f\n" \
535 "0:\t.quad " #x "@indntpoff\n" \
536 "1:\t lg %0,0(%0)\n\t" \
537 "lg %0,0(%0):tls_load:" #x \
538 : "=&a" (__offset) : : "cc" ); \
539 (int *) (__builtin_thread_pointer() + __offset); })
544 ({ unsigned long __offset, __save12; \
545 asm ("bras %0,1f\n" \
546 "0:\t.quad " #x "@tlsldm\n\t" \
547 ".quad " #x "@dtpoff\n" \
548 "1:\tlgr %1,%%r12\n\t" \
549 "larl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
550 "lg %%r2,0(%0)\n\t" \
551 "brasl %%r14,__tls_get_offset@plt:tls_ldcall:" #x "\n\t" \
555 : "=&a" (__offset), "=&a" (__save12) \
556 : : "cc", "0", "1", "2", "3", "4", "5", "14" ); \
557 (int *) (__builtin_thread_pointer() + __offset); })
560 ({ unsigned long __offset; \
561 asm ("bras %0,1f\n" \
562 "0:\t.quad " #x "@tlsldm\n\t" \
563 ".quad " #x "@dtpoff\n" \
564 "1:\tlarl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
565 "lg %%r2,0(%0)\n\t" \
566 "brasl %%r14,__tls_get_offset@plt:tls_ldcall:" #x "\n\t" \
570 : : "cc", "0", "1", "2", "3", "4", "5", "12", "14" ); \
571 (int *) (__builtin_thread_pointer() + __offset); })
576 ({ unsigned long __offset, __save12; \
577 asm ("bras %0,1f\n" \
578 "0:\t.quad " #x "@tlsgd\n" \
579 "1:\tlgr %1,%%r12\n\t" \
580 "larl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
581 "lg %%r2,0(%0)\n\t" \
582 "brasl %%r14,__tls_get_offset@plt:tls_gdcall:" #x "\n\t" \
585 : "=&a" (__offset), "=&a" (__save12) \
586 : : "cc", "0", "1", "2", "3", "4", "5", "14" ); \
587 (int *) (__builtin_thread_pointer() + __offset); })
590 ({ unsigned long __offset; \
591 asm ("bras %0,1f\n" \
592 "0:\t.quad " #x "@tlsgd\n" \
593 "1:\tlarl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
594 "lg %%r2,0(%0)\n\t" \
595 "brasl %%r14,__tls_get_offset@plt:tls_gdcall:" #x "\n\t" \
598 : : "cc", "0", "1", "2", "3", "4", "5", "12", "14" ); \
599 (int *) (__builtin_thread_pointer() + __offset); })
602 #elif defined __s390__
605 ({ unsigned long __offset; \
606 asm ("bras %0,1f\n" \
607 "0:\t.long " #x "@ntpoff\n" \
609 : "=a" (__offset) : : "cc" ); \
610 (int *) (__builtin_thread_pointer() + __offset); })
614 ({ unsigned long __offset; \
615 asm ("bras %0,1f\n" \
616 "0:\t.long " #x "@gotntpoff\n" \
617 "1:\tl %0,0(%0)\n\t" \
618 "l %0,0(%0,%%r12):tls_load:" #x \
619 : "=&a" (__offset) : : "cc" ); \
620 (int *) (__builtin_thread_pointer() + __offset); })
623 ({ unsigned long __offset; \
624 asm ("bras %0,1f\n" \
625 "0:\t.long " #x "@indntpoff\n" \
626 "1:\t l %0,0(%0)\n\t" \
627 "l %0,0(%0):tls_load:" #x \
628 : "=&a" (__offset) : : "cc" ); \
629 (int *) (__builtin_thread_pointer() + __offset); })
634 ({ unsigned long __offset, __save12; \
635 asm ("bras %0,1f\n" \
636 "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \
637 ".long __tls_get_offset@plt-0b\n\t" \
638 ".long " #x "@tlsldm\n\t" \
639 ".long " #x "@dtpoff\n" \
640 "1:\tlr %1,%%r12\n\t" \
641 "l %%r12,0(%0)\n\t" \
642 "la %%r12,0(%%r12,%0)\n\t" \
645 "bas %%r14,0(%%r1,%0):tls_ldcall:" #x "\n\t" \
649 : "=&a" (__offset), "=&a" (__save12) \
650 : : "cc", "0", "1", "2", "3", "4", "5" ); \
651 (int *) (__builtin_thread_pointer() + __offset); })
654 ({ unsigned long __offset; \
655 asm ("bras %0,1f\n" \
656 "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t" \
657 ".long __tls_get_offset@plt\n\t" \
658 ".long " #x "@tlsldm\n\t" \
659 ".long " #x "@dtpoff\n" \
660 "1:\tl %%r12,0(%0)\n\t" \
663 "bas %%r14,0(%%r1):tls_ldcall:" #x "\n\t" \
666 : "=&a" (__offset) : : "cc", "0", "1", "2", "3", "4", "5", "12" ); \
667 (int *) (__builtin_thread_pointer() + __offset); })
672 ({ unsigned long __offset, __save12; \
673 asm ("bras %0,1f\n" \
674 "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \
675 ".long __tls_get_offset@plt-0b\n\t" \
676 ".long " #x "@tlsgd\n" \
677 "1:\tlr %1,%%r12\n\t" \
678 "l %%r12,0(%0)\n\t" \
679 "la %%r12,0(%%r12,%0)\n\t" \
682 "bas %%r14,0(%%r1,%0):tls_gdcall:" #x "\n\t" \
685 : "=&a" (__offset), "=&a" (__save12) \
686 : : "cc", "0", "1", "2", "3", "4", "5" ); \
687 (int *) (__builtin_thread_pointer() + __offset); })
690 ({ unsigned long __offset; \
691 asm ("bras %0,1f\n" \
692 "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t" \
693 ".long __tls_get_offset@plt\n\t" \
694 ".long " #x "@tlsgd\n" \
695 "1:\tl %%r12,0(%0)\n\t" \
698 "bas %%r14,0(%%r1):tls_gdcall:" #x "\n\t" \
700 : "=&a" (__offset) : : "cc", "0", "1", "2", "3", "4", "5", "12" ); \
701 (int *) (__builtin_thread_pointer() + __offset); })
704 #elif defined __powerpc__
706 # define __TLS_CALL_CLOBBERS \
707 "0", "4", "5", "6", "7", "8", "9", "10", "11", "12", \
708 "lr", "ctr", "cr0", "cr1", "cr5", "cr6", "cr7"
710 # ifndef __powerpc64__
714 /* PowerPC32 Local Exec TLS access. */
717 asm ("addi %0,2," #x "@tprel" \
718 : "=r" (__result)); \
721 /* PowerPC32 Initial Exec TLS access. */
722 # ifdef HAVE_ASM_PPC_REL16
725 asm ("bcl 20,31,1f\n1:\t" \
727 "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
728 "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
729 "lwz %0," #x "@got@tprel(%0)\n\t" \
730 "add %0,%0," #x "@tls" \
731 : "=b" (__result) : \
737 asm ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
739 "lwz %0," #x "@got@tprel(%0)\n\t" \
740 "add %0,%0," #x "@tls" \
741 : "=b" (__result) : \
746 /* PowerPC32 Local Dynamic TLS access. */
747 # ifdef HAVE_ASM_PPC_REL16
750 asm ("bcl 20,31,1f\n1:\t" \
752 "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
753 "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
754 "addi 3,3," #x "@got@tlsld\n\t" \
755 "bl __tls_get_addr@plt\n\t" \
756 "addi %0,3," #x "@dtprel" \
757 : "=r" (__result) : \
758 : "3", __TLS_CALL_CLOBBERS); \
763 asm ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
765 "addi 3,3," #x "@got@tlsld\n\t" \
766 "bl __tls_get_addr@plt\n\t" \
767 "addi %0,3," #x "@dtprel" \
768 : "=r" (__result) : \
769 : "3", __TLS_CALL_CLOBBERS); \
773 /* PowerPC32 General Dynamic TLS access. */
774 # ifdef HAVE_ASM_PPC_REL16
776 ({ register int *__result __asm__ ("r3"); \
777 asm ("bcl 20,31,1f\n1:\t" \
779 "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
780 "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
781 "addi 3,3," #x "@got@tlsgd\n\t" \
782 "bl __tls_get_addr@plt" \
783 : "=r" (__result) : \
784 : __TLS_CALL_CLOBBERS); \
788 ({ register int *__result __asm__ ("r3"); \
789 asm ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
791 "addi 3,3," #x "@got@tlsgd\n\t" \
792 "bl __tls_get_addr@plt" \
793 : "=r" (__result) : \
794 : __TLS_CALL_CLOBBERS); \
800 /* PowerPC64 Local Exec TLS access. */
803 asm ("addis %0,13," #x "@tprel@ha\n\t" \
804 "addi %0,%0," #x "@tprel@l" \
805 : "=b" (__result) ); \
808 /* PowerPC64 Initial Exec TLS access. */
811 asm ("ld %0," #x "@got@tprel(2)\n\t" \
812 "add %0,%0," #x "@tls" \
813 : "=r" (__result) ); \
816 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
817 # define __TLS_GET_ADDR ".__tls_get_addr"
819 # define __TLS_GET_ADDR "__tls_get_addr"
821 /* PowerPC64 Local Dynamic TLS access. */
824 asm ("addi 3,2," #x "@got@tlsld\n\t" \
825 "bl " __TLS_GET_ADDR "\n\t" \
827 "addis %0,3," #x "@dtprel@ha\n\t" \
828 "addi %0,%0," #x "@dtprel@l" \
829 : "=b" (__result) : \
830 : "3", __TLS_CALL_CLOBBERS); \
833 /* PowerPC64 General Dynamic TLS access. */
835 ({ register int *__result __asm__ ("r3"); \
836 asm ("addi 3,2," #x "@got@tlsgd\n\t" \
837 "bl " __TLS_GET_ADDR "\n\t" \
839 : "=r" (__result) : \
840 : __TLS_CALL_CLOBBERS); \
845 #elif !defined TLS_LE || !defined TLS_IE \
846 || !defined TLS_LD || !defined TLS_GD
847 # error "No support for this architecture so far."