1 | #include <dlfcn.h> |
---|---|
2 | #include <stdio.h> |
3 | #include <stdlib.h> |
4 | |
5 | |
6 | static int |
7 | do_test (void) |
8 | { |
9 | static const char modname[] = "tst-tlsmod2.so"; |
10 | int result = 0; |
11 | int *foop; |
12 | int (*fp) (int, int *); |
13 | void *h; |
14 | |
15 | h = dlopen (file: modname, RTLD_LAZY); |
16 | if (h == NULL) |
17 | { |
18 | printf (format: "cannot open '%s': %s\n", modname, dlerror ()); |
19 | exit (status: 1); |
20 | } |
21 | |
22 | fp = dlsym (handle: h, name: "in_dso"); |
23 | if (fp == NULL) |
24 | { |
25 | printf (format: "cannot get symbol 'in_dso': %s\n", dlerror ()); |
26 | exit (status: 1); |
27 | } |
28 | |
29 | result |= fp (0, NULL); |
30 | |
31 | foop = dlsym (handle: h, name: "foo"); |
32 | if (foop == NULL) |
33 | { |
34 | printf (format: "cannot get symbol 'foo' the second time: %s\n", dlerror ()); |
35 | exit (status: 1); |
36 | } |
37 | if (*foop != 16) |
38 | { |
39 | puts (s: "foo != 16"); |
40 | result = 1; |
41 | } |
42 | |
43 | dlclose (handle: h); |
44 | |
45 | return result; |
46 | } |
47 | |
48 | |
49 | #include <support/test-driver.c> |
50 |