Back to index

glibc  2.9
tst-global1.c
Go to the documentation of this file.
00001 #include <dlfcn.h>
00002 #include <stdio.h>
00003 
00004 int
00005 main (void)
00006 {
00007   void *h1 = dlopen ("$ORIGIN/testobj6.so", RTLD_GLOBAL|RTLD_LAZY);
00008   if (h1 == NULL)
00009     {
00010       puts ("cannot open testobj6");
00011       return 1;
00012     }
00013 
00014   void *h2 = dlopen ("$ORIGIN/testobj2.so",
00015                    RTLD_GLOBAL|RTLD_DEEPBIND|RTLD_LAZY);
00016   if (h2 == NULL)
00017     {
00018       puts ("cannot open testobj2");
00019       return 1;
00020     }
00021 
00022   dlclose (h1);
00023 
00024   void (*f) (void) = dlsym (h2, "p");
00025   if (f == NULL)
00026     {
00027       puts ("cannot find p");
00028       return 1;
00029     }
00030 
00031   f ();
00032 
00033   dlclose (h2);
00034 
00035   return 0;
00036 }