Back to index

glibc  2.9
tst-pathopt.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 *h;
00011   int (*fp) (int);
00012   int result;
00013 
00014   mtrace ();
00015 
00016   h = dlopen ("renamed.so", RTLD_LAZY);
00017   if (h == NULL)
00018     {
00019       printf ("failed to load \"%s\": %s\n", "renamed.so", dlerror ());
00020       exit (1);
00021     }
00022 
00023   fp = dlsym (h, "in_renamed");
00024   if (fp == NULL)
00025     {
00026       printf ("lookup of \"%s\" failed: %s\n", "in_renamed", dlerror ());
00027       exit (1);
00028     }
00029 
00030   result = fp (10);
00031 
00032   if (dlclose (h) != 0)
00033     {
00034       printf ("failed to close \"%s\": %s\n", "renamed.so", dlerror ());
00035       exit (1);
00036     }
00037 
00038   return result;
00039 }