Back to index

glibc  2.9
resolvfail.c
Go to the documentation of this file.
00001 #include <dlfcn.h>
00002 #include <stdio.h>
00003 
00004 static const char obj[] = "testobj1.so";
00005 
00006 int
00007 main (void)
00008 {
00009   void *d = dlopen (obj, RTLD_LAZY);
00010   int n;
00011 
00012   if (d == NULL)
00013     {
00014       printf ("cannot load %s: %s\n", obj, dlerror ());
00015       return 1;
00016     }
00017 
00018   for (n = 0; n < 10000; ++n)
00019     if (dlsym (d, "does not exist") != NULL)
00020       {
00021        puts ("dlsym() did not fail");
00022        return 1;
00023       }
00024     else if (dlerror () == NULL)
00025       {
00026        puts ("dlerror() didn't return a string");
00027        return 1;
00028       }
00029 
00030   return 0;
00031 }