8 #define MAPS ((struct link_map *) _r_debug.r_map)
11 check_loaded_objects (const char **loaded
)
18 for (n
= 0; loaded
[n
]; n
++)
23 found
= (int *) alloca (sizeof (int) * n
);
24 memset (found
, 0, sizeof (int) * n
);
28 printf(" --------------------------------------------------------\n");
29 for (lm
= MAPS
; lm
; lm
= lm
->l_next
)
31 if (lm
->l_name
&& lm
->l_name
[0])
32 printf(" %s, count = %d\n", lm
->l_name
, (int) lm
->l_direct_opencount
);
33 if (lm
->l_type
== lt_loaded
&& lm
->l_name
)
36 for (n
= 0; loaded
[n
] != NULL
; n
++)
38 if (strcmp (basename (loaded
[n
]), basename (lm
->l_name
)) == 0)
49 printf ("ERRORS: %s is not unloaded\n", lm
->l_name
);
54 for (n
= 0; loaded
[n
] != NULL
; n
++)
59 printf ("ERRORS: %s is not loaded\n", loaded
[n
]);
72 const char *loaded
[] = { NULL
, NULL
, NULL
, NULL
, NULL
};
75 printf ("\nThis is what is in memory now:\n");
76 errors
+= check_loaded_objects (loaded
);
78 printf ("Now loading shared object neededobj2.so\n");
79 obj2
= dlopen ("neededobj2.so", RTLD_LAZY
);
82 printf ("%s\n", dlerror ());
85 loaded
[0] = "neededobj1.so";
86 loaded
[1] = "neededobj2.so";
87 errors
+= check_loaded_objects (loaded
);
89 printf( "Loading shared object neededobj3.so\n");
90 obj3
= dlopen( "neededobj3.so", RTLD_LAZY
);
93 printf ("%s\n", dlerror ());
96 loaded
[2] = "neededobj3.so";
97 errors
+= check_loaded_objects (loaded
);
100 printf( "Loading shared object neededobj4.so\n");
101 obj4
= dlopen( "neededobj4.so", RTLD_LAZY
);
104 printf ("%s\n", dlerror ());
107 loaded
[3] = "neededobj4.so";
108 errors
+= check_loaded_objects (loaded
);
110 printf ("Closing neededobj2.so\n");
112 errors
+= check_loaded_objects (loaded
);
114 printf ("Closing neededobj3.so\n");
116 errors
+= check_loaded_objects (loaded
);
118 printf ("Closing neededobj4.so\n");
124 errors
+= check_loaded_objects (loaded
);
127 printf ("%d errors found\n", errors
);