1/* Check alignment of TLS variable. */
2#include <dlfcn.h>
3#include <stdint.h>
4#include <stdio.h>
5#include <stdlib.h>
6
7#define AL 4096
8struct foo
9{
10 int i;
11} __attribute ((aligned (AL)));
12
13static __thread struct foo f;
14static struct foo g;
15
16
17extern int in_dso1 (void);
18
19
20static int
21do_test (void)
22{
23 int result = 0;
24
25 int fail = (((uintptr_t) &f) & (AL - 1)) != 0;
26 printf (format: "&f = %p %s\n", &f, fail ? "FAIL" : "OK");
27 result |= fail;
28
29 fail = (((uintptr_t) &g) & (AL - 1)) != 0;
30 printf (format: "&g = %p %s\n", &g, fail ? "FAIL" : "OK");
31 result |= fail;
32
33 result |= in_dso1 ();
34
35 void *h = dlopen (file: "tst-tlsmod14b.so", RTLD_LAZY);
36 if (h == NULL)
37 {
38 printf (format: "cannot open tst-tlsmod14b.so: %m\n");
39 exit (status: 1);
40 }
41
42 int (*fp) (void) = (int (*) (void)) dlsym (handle: h, name: "in_dso2");
43 if (fp == NULL)
44 {
45 puts (s: "cannot find in_dso2");
46 exit (status: 1);
47 }
48
49 result |= fp ();
50
51 return result;
52}
53
54#include <support/test-driver.c>
55

source code of glibc/elf/tst-tls14.c