Back to index

glibc  2.9
unload6.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 ("unload6mod1.so", RTLD_LAZY);
00008   if (h == NULL)
00009     {
00010       puts ("dlopen unload6mod1.so failed");
00011       return 1;
00012     }
00013 
00014   int (*fn) (int);
00015   fn = dlsym (h, "foo");
00016   if (fn == NULL)
00017     {
00018       puts ("dlsym failed");
00019       return 1;
00020     }
00021 
00022   int val = fn (16);
00023   if (val != 24)
00024     {
00025       printf ("foo returned %d != 24\n", val);
00026       return 1;
00027     }
00028 
00029   return 0;
00030 }