1 /* shared library to test for __tls_get_addr optimization. */
6 __thread
int foo
__attribute__ ((tls_model("global-dynamic")));
10 tls_get_addr_opt_test (void)
14 /* Get variable using general dynamic model. */
18 printf ("foo = %d\n", *ap
);
24 register unsigned long thread_pointer
__asm__ ("r13");
26 asm ("paddi %0,0,foo@got@tlsgd@pcrel,1" : "=b" (tls_arg
));
28 asm ("addi %0,2,foo@got@tlsgd" : "=b" (tls_arg
));
31 register unsigned long thread_pointer
__asm__ ("r2");
32 asm ("bcl 20,31,1f\n1:\t"
34 "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t"
35 "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t"
36 "addi %0,%0,foo@got@tlsgd" : "=b" (tls_arg
));
39 if (tls_arg
->ti_module
!= 0)
41 printf ("tls_index not optimized, binutils too old?\n");
44 else if (tls_arg
->ti_offset
+ thread_pointer
!= (unsigned long) ap
)
46 printf ("tls_index->ti_offset wrong value\n");