xref: /third_party/musl/libc-test/src/functional/tls_align_dlopen.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/musl/libc-test/src/functional/
1570af302Sopenharmony_ci#include <dlfcn.h>
2570af302Sopenharmony_ci#include "test.h"
3570af302Sopenharmony_ci
4570af302Sopenharmony_ciint main(int argc, char *argv[])
5570af302Sopenharmony_ci{
6570af302Sopenharmony_ci	int i;
7570af302Sopenharmony_ci	void *h;
8570af302Sopenharmony_ci	struct {
9570af302Sopenharmony_ci		char *name;
10570af302Sopenharmony_ci		unsigned size;
11570af302Sopenharmony_ci		unsigned align;
12570af302Sopenharmony_ci		unsigned long addr;
13570af302Sopenharmony_ci	} *t;
14570af302Sopenharmony_ci	char buf[512];
15570af302Sopenharmony_ci
16570af302Sopenharmony_ci	t_pathrel(buf, sizeof buf, argv[0], "libtls_align_dso.so");
17570af302Sopenharmony_ci	h = dlopen(buf, RTLD_LAZY);
18570af302Sopenharmony_ci	if (!h)
19570af302Sopenharmony_ci		t_error("dlopen failed\n");
20570af302Sopenharmony_ci	t = dlsym(h, "t");
21570af302Sopenharmony_ci	if (!t)
22570af302Sopenharmony_ci		t_error("dlsym failed\n");
23570af302Sopenharmony_ci	else for (i = 0; i < 4; i++) {
24570af302Sopenharmony_ci		if (!t[i].name)
25570af302Sopenharmony_ci			t_error("name is not set for t[%d]\n", i);
26570af302Sopenharmony_ci		if (t[i].addr & (t[i].align-1))
27570af302Sopenharmony_ci			t_error("bad alignment: %s, size: %u, align: %u, addr: 0x%lx\n",
28570af302Sopenharmony_ci				t[i].name, t[i].size, t[i].align, t[i].addr);
29570af302Sopenharmony_ci	}
30570af302Sopenharmony_ci	return t_status;
31570af302Sopenharmony_ci}
32

Indexes created Thu Nov 07 10:32:03 CST 2024