Back to index

glibc  2.9
unload7.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 *h = dlopen ("$ORIGIN/unload7mod1.so", RTLD_LAZY);
00008   if (h == NULL)
00009     {
00010       puts ("dlopen unload7mod1.so failed");
00011       return 1;
00012     }
00013 
00014   int (*fn) (void);
00015   fn = dlsym (h, "foo");
00016   if (fn == NULL)
00017     {
00018       puts ("dlsym failed");
00019       return 1;
00020     }
00021 
00022   int ret = 0;
00023   if (fn () == 0)
00024     ++ret;
00025 
00026   void *h2 = dlopen ("$ORIGIN/unload7mod2.so", RTLD_LAZY);
00027   if (h2 == NULL)
00028     {
00029       puts ("dlopen unload7mod2.so failed");
00030       return 1;
00031     }
00032   dlclose (h2);
00033 
00034   if (fn () == 0)
00035     ++ret;
00036 
00037   dlclose (h);
00038   return ret;
00039 }