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