.
[glibc/history.git] / elf / unload4.c
blob6e171a22e09d5aee51d02d53f8efcec7cb20aa51
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <malloc.h>
5 int
6 main (void)
8 #ifdef M_PERTURB
9 mallopt (M_PERTURB, 0xaa);
10 #endif
12 void *h;
13 int (*fn) (int);
14 h = dlopen ("unload4mod1.so", RTLD_LAZY);
15 if (h == NULL)
17 puts ("1st dlopen failed");
18 return 1;
20 fn = dlsym (h, "foo");
21 if (fn == NULL)
23 puts ("dlsym failed");
24 return 1;
26 int n = fn (10);
27 if (n != 28)
29 printf ("foo (10) returned %d != 28\n", n);
30 return 1;
32 dlclose (h);
33 h = dlopen ("unload4mod3.so", RTLD_LAZY);
34 fn = dlsym (h, "mod3fn2");
35 if (fn == NULL)
37 puts ("second dlsym failed");
38 return 1;
40 n = fn (10);
41 if (n != 22)
43 printf ("mod3fn2 (10) returned %d != 22\n", n);
44 return 1;
46 dlclose (h);
47 return 0;