Add a test for BZ #15674
[glibc.git] / elf / tst-tls14.c
blobffd31e97be324c481c7ed1aaf6bea1343101ab90
1 /* Check alignment of TLS variable. */
2 #include <dlfcn.h>
3 #include <stdint.h>
4 #include <stdio.h>
5 #include <stdlib.h>
7 #include <tls.h>
9 #define AL 4096
10 struct foo
12 int i;
13 } __attribute ((aligned (AL)));
15 static __thread struct foo f;
16 static struct foo g;
19 extern int in_dso1 (void);
22 static int
23 do_test (void)
25 int result = 0;
27 int fail = (((uintptr_t) &f) & (AL - 1)) != 0;
28 printf ("&f = %p %s\n", &f, fail ? "FAIL" : "OK");
29 result |= fail;
31 fail = (((uintptr_t) &g) & (AL - 1)) != 0;
32 printf ("&g = %p %s\n", &g, fail ? "FAIL" : "OK");
33 result |= fail;
35 result |= in_dso1 ();
37 void *h = dlopen ("tst-tlsmod14b.so", RTLD_LAZY);
38 if (h == NULL)
40 printf ("cannot open tst-tlsmod14b.so: %m\n");
41 exit (1);
44 int (*fp) (void) = (int (*) (void)) dlsym (h, "in_dso2");
45 if (fp == NULL)
47 puts ("cannot find in_dso2");
48 exit (1);
51 result |= fp ();
53 return result;
56 #define TEST_FUNCTION do_test ()
57 #include "../test-skeleton.c"