Back to index

glibc  2.9
bug-dlsym1.c
Go to the documentation of this file.
00001 /* Test case for bug in dlsym accessing dependency objects' symbols.  */
00002 
00003 #include <stdlib.h>
00004 #include <stdio.h>
00005 #include <unistd.h>
00006 #include <dlfcn.h>
00007 
00008 int main(void)
00009 {
00010     void *handle;
00011     char *c;
00012 
00013     /* open lib1.so, which has the unresolved test symbol and a DT_NEEDED
00014        on lib2.so, which provides the symbol */
00015     if ((handle = dlopen("bug-dlsym1-lib1.so", RTLD_NOW)) == NULL) {
00016        printf("dlopen(\"bug-dlsym1-lib1.so\"): %s\n", dlerror());
00017        abort();
00018     }
00019 
00020     if ((c = dlsym(handle, "dlopen_test_variable")) == NULL) {
00021        printf("dlsym(handle, \"dlopen_test_variable\"): %s\n", dlerror());
00022        abort();
00023     }
00024 
00025     (void) dlclose(handle);
00026 
00027     return 0;
00028 }