[BZ #5186]
[glibc.git] / elf / dblunload.c
blobab0b2a5e9e8f85a960c44272b9f0a1f9939fc6e2
1 #include <dlfcn.h>
2 #include <mcheck.h>
3 #include <stdio.h>
4 #include <stdlib.h>
7 int
8 main (void)
10 void *p1;
11 void *p2;
12 int (*fp) (void);
13 int result;
15 mtrace ();
17 p1 = dlopen ("dblloadmod1.so", RTLD_LAZY);
18 if (p1 == NULL)
20 printf ("cannot load dblloadmod1.so: %s\n", dlerror ());
21 exit (EXIT_FAILURE);
24 p2 = dlopen ("dblloadmod2.so", RTLD_LAZY);
25 if (p2 == NULL)
27 printf ("cannot load dblloadmod2.so: %s\n", dlerror ());
28 exit (EXIT_FAILURE);
31 if (dlclose (p1) != 0)
33 printf ("error while closing dblloadmod1.so: %s\n", dlerror ());
34 exit (EXIT_FAILURE);
37 fp = dlsym (p2, "xyzzy");
38 if (fp == NULL)
40 printf ("cannot get function \"xyzzy\": %s\n", dlerror ());
41 exit (EXIT_FAILURE);
44 result = fp ();
46 if (dlclose (p2) != 0)
48 printf ("error while closing dblloadmod2.so: %s\n", dlerror ());
49 exit (EXIT_FAILURE);
52 return result;