Back to index

glibc  2.9
constload1.c
Go to the documentation of this file.
00001 #include <dlfcn.h>
00002 #include <errno.h>
00003 #include <error.h>
00004 #include <mcheck.h>
00005 #include <stdio.h>
00006 #include <stdlib.h>
00007 
00008 int
00009 main (void)
00010 {
00011   int (*foo) (void);
00012   void *h;
00013   int ret;
00014 
00015   mtrace ();
00016 
00017   h = dlopen ("constload2.so", RTLD_LAZY | RTLD_GLOBAL);
00018   if (h == NULL)
00019     error (EXIT_FAILURE, errno, "cannot load module \"constload2.so\"");
00020   foo = dlsym (h, "foo");
00021   ret = foo ();
00022   /* Note that the following dlclose() call cannot unload the objects.
00023      Due to the introduced relocation dependency constload2.so depends
00024      on constload3.so and the dependencies of constload2.so on constload3.so
00025      is not visible to ld.so since it's done using dlopen().  */
00026   if (dlclose (h) != 0)
00027     {
00028       puts ("failed to close");
00029       exit (EXIT_FAILURE);
00030     }
00031   return ret;
00032 }