Ignore undefined symbols for -mtls-dialect=gnu2
[glibc.git] / elf / tst-tls1.c
blobb3412213ee9eaa7e1be6022c2a9b742c3ca1d44f
1 /* glibc test for TLS in ld.so. */
2 #include <stdio.h>
5 __thread int foo, bar __attribute__ ((tls_model("local-exec")));
6 extern __thread int foo_gd asm ("foo") __attribute__ ((tls_model("global-dynamic")));
7 extern __thread int foo_ld asm ("foo") __attribute__ ((tls_model("local-dynamic")));
8 extern __thread int foo_ie asm ("foo") __attribute__ ((tls_model("initial-exec")));
9 extern __thread int bar_gd asm ("bar") __attribute__ ((tls_model("global-dynamic")));
10 extern __thread int bar_ld asm ("bar") __attribute__ ((tls_model("local-dynamic")));
11 extern __thread int bar_ie asm ("bar") __attribute__ ((tls_model("initial-exec")));
13 static int
14 do_test (void)
16 int result = 0;
17 int *ap, *bp;
20 /* Set the variable using the local exec model. */
21 puts ("set bar to 1 (LE)");
22 bar = 1;
25 /* Get variables using initial exec model. */
26 fputs ("get sum of foo and bar (IE)", stdout);
27 ap = &foo_ie;
28 bp = &bar_ie;
29 printf (" = %d\n", *ap + *bp);
30 result |= *ap + *bp != 1;
31 if (*ap != 0 || *bp != 1)
33 printf ("foo = %d\nbar = %d\n", *ap, *bp);
34 result = 1;
38 /* Get variables using local dynamic model or TLSDESC. */
39 fputs ("get sum of foo and bar (LD or TLSDESC)", stdout);
40 ap = &foo_ld;
41 bp = &bar_ld;
42 printf (" = %d\n", *ap + *bp);
43 result |= *ap + *bp != 1;
44 if (*ap != 0 || *bp != 1)
46 printf ("foo = %d\nbar = %d\n", *ap, *bp);
47 result = 1;
51 /* Get variables using general dynamic model or TLSDESC. */
52 fputs ("get sum of foo and bar (GD or TLSDESC)", stdout);
53 ap = &foo_gd;
54 bp = &bar_gd;
55 printf (" = %d\n", *ap + *bp);
56 result |= *ap + *bp != 1;
57 if (*ap != 0 || *bp != 1)
59 printf ("foo = %d\nbar = %d\n", *ap, *bp);
60 result = 1;
64 return result;
68 #include <support/test-driver.c>