1#include <config.h>
2#include <dlfcn.h>
3#include <stdio.h>
4#include <sys/mman.h>
5
6static int
7do_test (void)
8{
9 void *h1 = dlopen (file: "tst-unique1mod1.so", RTLD_LAZY);
10 if (h1 == NULL)
11 {
12 puts (s: "cannot load tst-unique1mod1");
13 return 1;
14 }
15 int *(*f1) (void) = dlsym (handle: h1, name: "f");
16 if (f1 == NULL)
17 {
18 puts (s: "cannot locate f in tst-unique1mod1");
19 return 1;
20 }
21 void *h2 = dlopen (file: "tst-unique1mod2.so", RTLD_LAZY);
22 if (h2 == NULL)
23 {
24 puts (s: "cannot load tst-unique1mod2");
25 return 1;
26 }
27 int (*f2) (int *) = dlsym (handle: h2, name: "f");
28 if (f2 == NULL)
29 {
30 puts (s: "cannot locate f in tst-unique1mod2");
31 return 1;
32 }
33 if (f2 (f1 ()))
34 {
35 puts (s: "f from tst-unique1mod2 failed");
36 return 1;
37 }
38 dlclose (handle: h2);
39 dlclose (handle: h1);
40 mmap (NULL, len: 1024 * 1024 * 16, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, fd: -1, offset: 0);
41 h2 = dlopen (file: "tst-unique1mod2.so", RTLD_LAZY);
42 if (h2 == NULL)
43 {
44 puts (s: "cannot load tst-unique1mod2");
45 return 1;
46 }
47 f2 = dlsym (handle: h2, name: "f");
48 if (f2 == NULL)
49 {
50 puts (s: "cannot locate f in tst-unique1mod2");
51 return 1;
52 }
53 h1 = dlopen (file: "tst-unique1mod1.so", RTLD_LAZY);
54 if (h1 == NULL)
55 {
56 puts (s: "cannot load tst-unique1mod1");
57 return 1;
58 }
59 f1 = dlsym (handle: h1, name: "f");
60 if (f1 == NULL)
61 {
62 puts (s: "cannot locate f in tst-unique1mod1");
63 return 1;
64 }
65 if (f2 (f1 ()))
66 {
67 puts (s: "f from tst-unique1mod2 failed");
68 return 1;
69 }
70 return 0;
71}
72
73#include <support/test-driver.c>
74

source code of glibc/elf/tst-unique1.c