1 /* glibc test for TLS in ld.so. */
7 /* XXX Until gcc gets told how to define and use thread-local
8 variables we will have to resort to use asms. */
9 //asm (".tls_common foo,4,4");
10 asm (".section \".tdata\", \"awT\", @progbits\n\t"
26 /* XXX Each architecture must have its own asm for now. */
28 /* Set the variable using the local exec model. */
29 puts ("set bar to 1 (LE)");
30 asm ("movl %gs:0,%eax\n\t"
31 "subl $bar@tpoff,%eax\n\t"
35 // XXX Doesn't work yet; no runtime relocations.
36 fputs ("get sum of foo and bar (IE)", stdout
);
39 "1:\tmovl (%%esp), %%ebx\n\t"
42 "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t"
43 "movl %%gs:0,%%eax\n\t"
44 "movl %%eax,%%edx\n\t"
45 "addl foo@gottpoff(%%ebx),%%eax\n\t"
46 "addl bar@gottpoff(%%ebx),%%eax\n\t"
47 "movl (%%eax), %0\n\t"
49 : "=a" (a
), "=&b" (b
));
50 printf (" = %d\n", a
);
54 fputs ("get sum of foo and bar (GD)", stdout
);
57 "1:\tmovl (%%esp), %%ebx\n\t"
60 "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t"
61 "leal foo@tlsgd(%%ebx),%%eax\n\t"
62 "call ___tls_get_addr@plt\n\t"
64 "movl (%%eax), %%edx\n\t"
65 "leal bar@tlsgd(%%ebx),%%eax\n\t"
66 "call ___tls_get_addr@plt\n\t"
68 "addl (%%eax), %%edx\n\t"
69 : "=&a" (a
), "=d" (b
));
70 printf (" = %d\n", b
);
74 # error "No support for this architecture so far."