Back to index

glibc  2.9
failtestmod.c
Go to the documentation of this file.
00001 #include <dlfcn.h>
00002 #include <stdio.h>
00003 
00004 
00005 extern void constr (void) __attribute__ ((__constructor__));
00006 void
00007 __attribute__ ((__constructor__))
00008 constr (void)
00009 {
00010   void *handle;
00011   void *m;
00012 
00013   /* Open the library.  */
00014   handle = dlopen (NULL, RTLD_NOW);
00015   if (handle == NULL)
00016     {
00017       puts ("Cannot get handle to own object");
00018       return;
00019     }
00020 
00021   /* Get a symbol.  */
00022   m = dlsym (handle, "main");
00023   puts ("called dlsym() to get main");
00024 
00025   dlclose (handle);
00026 }