Adjust for __libc_res_nquery and __libc_res_nsearch interface changes.
[glibc/history.git] / elf / unload3.c
blob6f1af707e6048be21f0bd5d95dcee8b31e820c9e
1 #include <dlfcn.h>
2 #include <stdio.h>
4 int
5 main (void)
7 void *g = dlopen ("unload3mod1.so", RTLD_GLOBAL | RTLD_NOW);
8 void *h = dlopen ("unload3mod2.so", RTLD_GLOBAL | RTLD_NOW);
9 if (g == NULL || h == NULL)
11 printf ("dlopen unload3mod{1,2}.so failed: %p %p\n", g, h);
12 return 1;
14 dlclose (h);
15 dlclose (g);
17 g = dlopen ("unload3mod3.so", RTLD_GLOBAL | RTLD_NOW);
18 h = dlopen ("unload3mod4.so", RTLD_GLOBAL | RTLD_NOW);
19 if (g == NULL || h == NULL)
21 printf ("dlopen unload3mod{3,4}.so failed: %p %p\n", g, h);
22 return 1;
25 int (*fn) (int);
26 fn = dlsym (h, "bar");
27 if (fn == NULL)
29 puts ("dlsym failed");
30 return 1;
33 int val = fn (16);
34 if (val != 24)
36 printf ("bar returned %d != 24\n", val);
37 return 1;
40 return 0;