Get rid of unused __swblk_t type.
[glibc.git] / elf / reldep5.c
blob881d519ff6a7d7f70cb499af4b8718bcff868bc4
1 #include <dlfcn.h>
2 #include <mcheck.h>
3 #include <stdio.h>
4 #include <stdlib.h>
6 int
7 main (void)
9 void *h1;
10 void *h2;
11 int (*fp) (void);
13 mtrace ();
15 /* Open the two objects. */
16 h1 = dlopen ("reldepmod5.so", RTLD_LAZY);
17 if (h1 == NULL)
19 printf ("cannot open reldepmod5.so: %s\n", dlerror ());
20 exit (1);
22 h2 = dlopen ("reldepmod6.so", RTLD_LAZY);
23 if (h2 == NULL)
25 printf ("cannot open reldepmod6.so: %s\n", dlerror ());
26 exit (1);
29 /* Get the address of the variable in reldepmod1.so. */
30 fp = dlsym (h2, "bar");
31 if (fp == NULL)
33 printf ("cannot get address of \"bar\": %s\n", dlerror ());
34 exit (1);
37 /* Call the function. */
38 puts ("calling fp for the first time");
39 if (fp () != 0)
41 puts ("function \"call_me\" returned wrong result");
42 exit (1);
45 /* Now close the first object. It must still be around since we have
46 an implicit dependency. */
47 if (dlclose (h1) != 0)
49 printf ("closing h1 failed: %s\n", dlerror ());
50 exit (1);
53 /* Calling the function must still work. */
54 puts ("calling fp for the second time");
55 if (fp () != 0)
57 puts ("function \"call_me\" the second time returned wrong result");
58 exit (1);
60 puts ("second call suceeded as well");
62 /* Close the second object, we are done. */
63 if (dlclose (h2) != 0)
65 printf ("closing h2 failed: %s\n", dlerror ());
66 exit (1);
69 return 0;