]> git.ipfire.org Git - thirdparty/glibc.git/blame - elf/tst-tls7.c
[BZ #2510, BZ #2830, BZ #3137, BZ #3313, BZ #3426, BZ #3465, BZ #3480, BZ #3483,...
[thirdparty/glibc.git] / elf / tst-tls7.c
CommitLineData
fc093be1
UD
1#include <dlfcn.h>
2#include <stdio.h>
3#include <stdlib.h>
4
5#include <link.h>
6#include <tls.h>
7
8
9#define TEST_FUNCTION do_test ()
10static int
11do_test (void)
12{
fc093be1
UD
13 static const char modname[] = "tst-tlsmod3.so";
14 int result = 0;
15 int (*fp) (void);
16 void *h;
17 int i;
18 int modid = -1;
19
20 for (i = 0; i < 10; ++i)
21 {
22 h = dlopen (modname, RTLD_LAZY);
23 if (h == NULL)
24 {
25 printf ("cannot open '%s': %s\n", modname, dlerror ());
26 exit (1);
27 }
28
29 /* Dirty test code here: we peek into a private data structure.
30 We make sure that the module gets assigned the same ID every
31 time. The value of the first round is used. */
32 if (modid == -1)
33 modid = ((struct link_map *) h)->l_tls_modid;
9cfd8172 34 else if (((struct link_map *) h)->l_tls_modid != (size_t) modid)
fc093be1 35 {
9cfd8172 36 printf ("round %d: modid now %zu, initially %d\n",
fc093be1
UD
37 i, ((struct link_map *) h)->l_tls_modid, modid);
38 result = 1;
39 }
40
41 fp = dlsym (h, "in_dso2");
42 if (fp == NULL)
43 {
44 printf ("cannot get symbol 'in_dso2': %s\n", dlerror ());
45 exit (1);
46 }
47
48 result |= fp ();
49
50 dlclose (h);
51 }
52
53 return result;
fc093be1
UD
54}
55
56
57#include "../test-skeleton.c"