1 /* Test for unloading (really unmapping) of objects. By Franz Sirl.
2 This test does not have to passed in all dlopen() et.al. implementation
3 since it is not required the unloading actually happens. But we
4 require it for glibc. */
12 #define MAPS ((struct link_map *) _r_debug.r_map)
15 for (map = MAPS; map != NULL; map = map->l_next) \
16 if (map->l_type == lt_loaded) \
17 printf ("name = \"%s\", direct_opencount = %d\n", \
18 map->l_name, (int) map->l_direct_opencount); \
40 sohandle = dlopen ("unloadmod.so", RTLD_NOW | RTLD_GLOBAL);
43 printf ("*** first dlopen failed: %s\n", dlerror ());
47 puts ("\nAfter loading unloadmod.so");
50 testdat = dlsym (sohandle, "testdat");
51 testdat->next = (void *) -1;
53 ret = dlclose (sohandle);
56 puts ("*** first dlclose failed");
60 puts ("\nAfter closing unloadmod.so");
63 sohandle = dlopen ("unloadmod.so", RTLD_NOW | RTLD_GLOBAL);
66 printf ("*** second dlopen failed: %s\n", dlerror ());
70 puts ("\nAfter loading unloadmod.so the second time");
73 testdat = dlsym (sohandle, "testdat");
74 if (testdat->next == (void *) -1)
76 puts ("*** testdat->next == (void *) -1");
80 ret = dlclose (sohandle);
83 puts ("*** second dlclose failed");
87 puts ("\nAfter closing unloadmod.so again");