Back to index

glibc  2.9
dblunload.c
Go to the documentation of this file.
00001 #include <dlfcn.h>
00002 #include <mcheck.h>
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005 
00006 
00007 int
00008 main (void)
00009 {
00010   void *p1;
00011   void *p2;
00012   int (*fp) (void);
00013   int result;
00014 
00015   mtrace ();
00016 
00017   p1 = dlopen ("dblloadmod1.so", RTLD_LAZY);
00018   if (p1 == NULL)
00019     {
00020       printf ("cannot load dblloadmod1.so: %s\n", dlerror ());
00021       exit (EXIT_FAILURE);
00022     }
00023 
00024   p2 = dlopen ("dblloadmod2.so", RTLD_LAZY);
00025   if (p2 == NULL)
00026     {
00027       printf ("cannot load dblloadmod2.so: %s\n", dlerror ());
00028       exit (EXIT_FAILURE);
00029     }
00030 
00031   if (dlclose (p1) != 0)
00032     {
00033       printf ("error while closing dblloadmod1.so: %s\n", dlerror ());
00034       exit (EXIT_FAILURE);
00035     }
00036 
00037   fp = dlsym (p2, "xyzzy");
00038   if (fp == NULL)
00039     {
00040       printf ("cannot get function \"xyzzy\": %s\n", dlerror ());
00041       exit (EXIT_FAILURE);
00042     }
00043 
00044   result = fp ();
00045 
00046   if (dlclose (p2) != 0)
00047     {
00048       printf ("error while closing dblloadmod2.so: %s\n", dlerror ());
00049       exit (EXIT_FAILURE);
00050     }
00051 
00052   return result;
00053 }