]> git.ipfire.org Git - thirdparty/glibc.git/blob - elf/tst-tls5.c
Merge translations from the Translation Project
[thirdparty/glibc.git] / elf / tst-tls5.c
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4
5
6 #define TEST_FUNCTION do_test ()
7 static int
8 do_test (void)
9 {
10 static const char modname[] = "tst-tlsmod2.so";
11 int result = 0;
12 int *foop;
13 int *foop2;
14 int (*fp) (int, int *);
15 void *h;
16
17 h = dlopen (modname, RTLD_LAZY);
18 if (h == NULL)
19 {
20 printf ("cannot open '%s': %s\n", modname, dlerror ());
21 exit (1);
22 }
23
24 foop = dlsym (h, "foo");
25 if (foop == NULL)
26 {
27 printf ("cannot get symbol 'foo': %s\n", dlerror ());
28 exit (1);
29 }
30
31 *foop = 42;
32
33 fp = dlsym (h, "in_dso");
34 if (fp == NULL)
35 {
36 printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
37 exit (1);
38 }
39
40 result |= fp (42, foop);
41
42 foop2 = dlsym (h, "foo");
43 if (foop2 == NULL)
44 {
45 printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
46 exit (1);
47 }
48
49 if (foop != foop2)
50 {
51 puts ("address of 'foo' different the second time");
52 result = 1;
53 }
54 else if (*foop != 16)
55 {
56 puts ("foo != 16");
57 result = 1;
58 }
59
60 dlclose (h);
61
62 return result;
63 }
64
65
66 #include "../test-skeleton.c"