aboutsummaryrefslogtreecommitdiff
path: root/elf/neededtest.c
diff options
context:
space:
mode:
Diffstat (limited to 'elf/neededtest.c')
-rw-r--r--elf/neededtest.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/elf/neededtest.c b/elf/neededtest.c
index 98f69a3185..a33d243651 100644
--- a/elf/neededtest.c
+++ b/elf/neededtest.c
@@ -64,7 +64,7 @@ check_loaded_objects (const char **loaded)
int
main (void)
{
- void *obj2;
+ void *obj2[2];
void *obj3;
const char *loaded[] = { NULL, NULL, NULL, NULL };
int errors = 0;
@@ -84,7 +84,16 @@ main (void)
loaded[2] = "neededobj3.so";
errors += check_loaded_objects (loaded);
printf ("Now loading shared object neededobj2.so\n");
- obj2 = dlopen ("neededobj2.so", RTLD_LAZY);
+ obj2[0] = dlopen ("neededobj2.so", RTLD_LAZY);
+ if (obj2 == NULL)
+ {
+ printf ("%s\n", dlerror ());
+ exit (1);
+ }
+ printf ("After loading neededobj2.so once\n");
+ errors += check_loaded_objects (loaded);
+ printf ("And loading shared object neededobj2.so again\n");
+ obj2[1] = dlopen ("neededobj2.so", RTLD_LAZY);
if (obj2 == NULL)
{
printf ("%s\n", dlerror ());
@@ -92,12 +101,17 @@ main (void)
}
printf ("Again, this is what is in memory\n");
errors += check_loaded_objects (loaded);
- printf ("Closing neededobj2.so\n");
- dlclose (obj2);
+ printf ("Closing neededobj2.so for the first time\n");
+ dlclose (obj2[0]);
errors += check_loaded_objects (loaded);
printf ("Closing neededobj3.so\n");
dlclose (obj3);
+ loaded[2] = NULL;
+ errors += check_loaded_objects (loaded);
+ printf ("Closing neededobj2.so for the second time\n");
+ dlclose (obj2[1]);
loaded[0] = NULL;
+ loaded[1] = NULL;
errors += check_loaded_objects (loaded);
if (errors != 0)
printf ("%d errors found\n", errors);