1 /* shared library to test for __tls_get_addr optimization. */
4 #include "../../elf/tls-macros.h"
7 /* common 'int' variable in TLS. */
12 tls_get_addr_opt_test (void)
16 /* Get variable using general dynamic model. */
17 int *ap
= TLS_GD (foo
);
20 printf ("foo = %d\n", *ap
);
26 register unsigned long thread_pointer
__asm__ ("r13");
27 asm ("addi %0,2,foo@got@tlsgd" : "=r" (tls_arg
));
29 register unsigned long thread_pointer
__asm__ ("r2");
30 asm ("bcl 20,31,1f\n1:\t"
32 "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t"
33 "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t"
34 "addi %0,%0,foo@got@tlsgd" : "=b" (tls_arg
));
37 if (tls_arg
->ti_module
!= 0)
39 printf ("tls_index not optimized, binutils too old?\n");
42 else if (tls_arg
->ti_offset
+ thread_pointer
!= (unsigned long) ap
)
44 printf ("tls_index->ti_offset wrong value\n");