Updated to fedora-glibc-20090424T1908
[glibc/history.git] / elf / reldep7.c
blob5275a0e8f1ef1847d62884ec4b1fbc43d36e3c06
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <stdlib.h>
5 int
6 main (void)
8 void *h1;
9 void *h2;
10 void *mod1_bar, *mod2_bar;
12 h1 = dlopen ("reldep7mod1.so", RTLD_GLOBAL | RTLD_LAZY);
13 if (h1 == NULL)
15 printf ("cannot open reldep7mod1.so: %s\n", dlerror ());
16 exit (1);
19 h2 = dlopen ("reldep7mod2.so", RTLD_GLOBAL | RTLD_LAZY);
20 if (h2 == NULL)
22 printf ("cannot open reldep7mod1.so: %s\n", dlerror ());
23 exit (1);
26 mod1_bar = dlsym (h1, "mod1_bar");
27 if (mod1_bar == NULL)
29 printf ("cannot get address of \"mod1_bar\": %s\n", dlerror ());
30 exit (1);
33 mod2_bar = dlsym (h2, "mod2_bar");
34 if (mod2_bar == NULL)
36 printf ("cannot get address of \"mod2_bar\": %s\n", dlerror ());
37 exit (1);
40 printf ("%d\n", ((int (*) (void)) mod1_bar) ());
41 printf ("%d\n", ((int (*) (void)) mod2_bar) ());
43 if (dlclose (h1) != 0)
45 printf ("closing h1 failed: %s\n", dlerror ());
46 exit (1);
49 printf ("%d\n", ((int (*) (void)) mod2_bar) ());
51 if (dlclose (h2) != 0)
53 printf ("closing h2 failed: %s\n", dlerror ());
54 exit (1);
57 return 0;