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_direct_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
]);
70 const char *loaded
[] = { NULL
, NULL
, NULL
, NULL
, NULL
};
73 printf ("\nThis is what is in memory now:\n");
74 errors
+= check_loaded_objects (loaded
);
76 printf ("Now loading shared object neededobj2.so\n");
77 obj2
= dlopen ("neededobj2.so", RTLD_LAZY
);
80 printf ("%s\n", dlerror ());
83 loaded
[0] = "neededobj1.so";
84 loaded
[1] = "neededobj2.so";
85 errors
+= check_loaded_objects (loaded
);
87 printf( "Loading shared object neededobj3.so\n");
88 obj3
= dlopen( "neededobj3.so", RTLD_LAZY
);
91 printf ("%s\n", dlerror ());
94 loaded
[2] = "neededobj3.so";
95 errors
+= check_loaded_objects (loaded
);
98 printf( "Loading shared object neededobj4.so\n");
99 obj4
= dlopen( "neededobj4.so", RTLD_LAZY
);
102 printf ("%s\n", dlerror ());
105 loaded
[3] = "neededobj4.so";
106 errors
+= check_loaded_objects (loaded
);
108 printf ("Closing neededobj2.so\n");
110 errors
+= check_loaded_objects (loaded
);
112 printf ("Closing neededobj3.so\n");
114 errors
+= check_loaded_objects (loaded
);
116 printf ("Closing neededobj4.so\n");
122 errors
+= check_loaded_objects (loaded
);
125 printf ("%d errors found\n", errors
);