15 /* Open the two objects. */
16 h1
= dlopen ("reldepmod5.so", RTLD_LAZY
);
19 printf ("cannot open reldepmod5.so: %s\n", dlerror ());
22 h2
= dlopen ("reldepmod6.so", RTLD_LAZY
);
25 printf ("cannot open reldepmod6.so: %s\n", dlerror ());
29 /* Get the address of the variable in reldepmod1.so. */
30 fp
= dlsym (h2
, "bar");
33 printf ("cannot get address of \"bar\": %s\n", dlerror ());
37 /* Call the function. */
38 puts ("calling fp for the first time");
41 puts ("function \"call_me\" returned wrong result");
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 ());
53 /* Calling the function must still work. */
54 puts ("calling fp for the second time");
57 puts ("function \"call_me\" the second time returned wrong result");
60 puts ("second call succeeded as well");
62 /* Close the second object, we are done. */
63 if (dlclose (h2
) != 0)
65 printf ("closing h2 failed: %s\n", dlerror ());