1#include <dlfcn.h>
2#include "test.h"
3
4int main(int argc, char *argv[])
5{
6	int i;
7	void *h;
8	struct {
9		char *name;
10		unsigned size;
11		unsigned align;
12		unsigned long addr;
13	} *t;
14	char buf[512];
15
16	t_pathrel(buf, sizeof buf, argv[0], "libtls_align_dso.so");
17	h = dlopen(buf, RTLD_LAZY);
18	if (!h)
19		t_error("dlopen failed\n");
20	t = dlsym(h, "t");
21	if (!t)
22		t_error("dlsym failed\n");
23	else for (i = 0; i < 4; i++) {
24		if (!t[i].name)
25			t_error("name is not set for t[%d]\n", i);
26		if (t[i].addr & (t[i].align-1))
27			t_error("bad alignment: %s, size: %u, align: %u, addr: 0x%lx\n",
28				t[i].name, t[i].size, t[i].align, t[i].addr);
29	}
30	return t_status;
31}
32