9 check_loaded_objects (const char **loaded
)
16 for (n
= 0; loaded
[n
]; n
++)
21 found
= (int *) alloca (sizeof (int) * n
);
22 memset (found
, 0, sizeof (int) * n
);
26 printf(" --------------------------------------------------------\n");
27 for (lm
= _r_debug
.r_map
; lm
; lm
= lm
->l_next
)
29 if (lm
->l_name
&& lm
->l_name
[0])
30 printf(" %s, count = %d\n", lm
->l_name
, (int) lm
->l_opencount
);
31 if (lm
->l_type
== lt_loaded
&& lm
->l_name
)
34 for (n
= 0; loaded
[n
] != NULL
; n
++)
36 if (strcmp (basename (loaded
[n
]), basename (lm
->l_name
)) == 0)
47 printf ("ERRORS: %s is not unloaded\n", lm
->l_name
);
52 for (n
= 0; loaded
[n
] != NULL
; n
++)
57 printf ("ERRORS: %s is not loaded\n", loaded
[n
]);
69 const char *loaded
[] = { NULL
, NULL
, NULL
, NULL
};
72 printf ("\nThis is what is in memory now:\n");
73 errors
+= check_loaded_objects (loaded
);
74 printf ("\nLoading shared object neededobj2.so\n");
75 obj2
= dlopen ("neededobj2.so", RTLD_LAZY
);
78 printf ("%s\n", dlerror ());
81 loaded
[0] = "neededobj1.so";
82 loaded
[1] = "neededobj2.so";
83 errors
+= check_loaded_objects (loaded
);
84 printf ("\nLoading shared object neededobj3.so\n");
85 obj3
[0] = dlopen( "neededobj3.so", RTLD_LAZY
);
88 printf ("%s\n", dlerror ());
91 loaded
[2] = "neededobj3.so";
92 errors
+= check_loaded_objects (loaded
);
93 printf ("\nNow loading shared object neededobj3.so again\n");
94 obj3
[1] = dlopen ("neededobj3.so", RTLD_LAZY
);
97 printf ("%s\n", dlerror ());
100 errors
+= check_loaded_objects (loaded
);
101 printf ("\nClosing neededobj3.so once\n");
103 errors
+= check_loaded_objects (loaded
);
104 printf ("\nClosing neededobj2.so\n");
106 errors
+= check_loaded_objects (loaded
);
107 printf ("\nClosing neededobj3.so for the second time\n");
112 errors
+= check_loaded_objects (loaded
);
114 printf ("%d errors found\n", errors
);