nonstring: Enable __FORTIFY_LEVEL=3
[glibc.git] / elf / tst-unique1.c
blobb5e53e49a0bd01069e43f460a33e81340e999de7
1 #include <config.h>
2 #include <dlfcn.h>
3 #include <stdio.h>
4 #include <sys/mman.h>
6 static int
7 do_test (void)
9 void *h1 = dlopen ("tst-unique1mod1.so", RTLD_LAZY);
10 if (h1 == NULL)
12 puts ("cannot load tst-unique1mod1");
13 return 1;
15 int *(*f1) (void) = dlsym (h1, "f");
16 if (f1 == NULL)
18 puts ("cannot locate f in tst-unique1mod1");
19 return 1;
21 void *h2 = dlopen ("tst-unique1mod2.so", RTLD_LAZY);
22 if (h2 == NULL)
24 puts ("cannot load tst-unique1mod2");
25 return 1;
27 int (*f2) (int *) = dlsym (h2, "f");
28 if (f2 == NULL)
30 puts ("cannot locate f in tst-unique1mod2");
31 return 1;
33 if (f2 (f1 ()))
35 puts ("f from tst-unique1mod2 failed");
36 return 1;
38 dlclose (h2);
39 dlclose (h1);
40 mmap (NULL, 1024 * 1024 * 16, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
41 h2 = dlopen ("tst-unique1mod2.so", RTLD_LAZY);
42 if (h2 == NULL)
44 puts ("cannot load tst-unique1mod2");
45 return 1;
47 f2 = dlsym (h2, "f");
48 if (f2 == NULL)
50 puts ("cannot locate f in tst-unique1mod2");
51 return 1;
53 h1 = dlopen ("tst-unique1mod1.so", RTLD_LAZY);
54 if (h1 == NULL)
56 puts ("cannot load tst-unique1mod1");
57 return 1;
59 f1 = dlsym (h1, "f");
60 if (f1 == NULL)
62 puts ("cannot locate f in tst-unique1mod1");
63 return 1;
65 if (f2 (f1 ()))
67 puts ("f from tst-unique1mod2 failed");
68 return 1;
70 return 0;
73 #include <support/test-driver.c>