elf: Ignore loader debug env vars for setuid
[glibc.git] / elf / tst-tls3.c
blob222b17962616189769efcb6c1e9fe3cf3306dd01
1 /* glibc test for TLS in ld.so. */
2 #include <stdio.h>
5 __thread int foo, bar __attribute__ ((tls_model("initial-exec")));
6 __thread int baz __attribute__ ((tls_model("local-exec")));
7 extern __thread int foo_gd __attribute__ ((alias("foo"), tls_model("global-dynamic")));
8 extern __thread int bar_gd __attribute__ ((alias("bar"), tls_model("global-dynamic")));
9 extern __thread int baz_ld __attribute__ ((alias("baz"), tls_model("local-dynamic")));
12 extern int in_dso (void);
15 static int
16 do_test (void)
18 int result = 0;
19 int *ap, *bp, *cp;
22 /* Set the variable using the local exec model. */
23 puts ("set baz to 3 (LE)");
24 baz = 3;
27 /* Get variables using initial exec model. */
28 puts ("set variables foo and bar (IE)");
29 foo = 1;
30 bar = 2;
33 /* Get variables using local dynamic model. */
34 fputs ("get sum of foo, bar (GD) and baz (LD)", stdout);
35 ap = &foo_gd;
36 bp = &bar_gd;
37 cp = &baz_ld;
38 printf (" = %d\n", *ap + *bp + *cp);
39 result |= *ap + *bp + *cp != 6;
40 if (*ap != 1)
42 printf ("foo = %d\n", *ap);
43 result = 1;
45 if (*bp != 2)
47 printf ("bar = %d\n", *bp);
48 result = 1;
50 if (*cp != 3)
52 printf ("baz = %d\n", *cp);
53 result = 1;
57 result |= in_dso ();
59 return result;
63 #include <support/test-driver.c>