]>
git.ipfire.org Git - thirdparty/glibc.git/blob - elf/circleload1.c
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
]);
65 load_dso (const char **loading
, int undef
, int flag
)
68 const char *loaded
[] = { NULL
, NULL
, NULL
, NULL
};
70 const char *errstring
;
72 printf ("\nThis is what is in memory now:\n");
73 errors
+= check_loaded_objects (loaded
);
75 printf ("Loading shared object %s: %s\n", loading
[0],
76 flag
== RTLD_LAZY
? "RTLD_LAZY" : "RTLD_NOW");
77 obj
= dlopen (loading
[0], flag
);
80 if (flag
== RTLD_LAZY
)
83 printf ("ERRORS: dlopen shouldn't fail for RTLD_LAZY\n");
86 errstring
= dlerror ();
87 if (strstr (errstring
, "undefined symbol") == 0
88 || strstr (errstring
, "circlemod2_undefined") == 0)
91 printf ("ERRORS: dlopen: `%s': Invalid error string\n",
95 printf ("dlopen: %s\n", errstring
);
99 if (undef
&& flag
== RTLD_NOW
)
102 printf ("ERRORS: dlopen shouldn't work for RTLD_NOW\n");
105 loaded
[0] = loading
[0];
106 loaded
[1] = loading
[1];
107 loaded
[2] = loading
[2];
109 errors
+= check_loaded_objects (loaded
);
113 printf ("UnLoading shared object %s\n", loading
[0]);
118 errors
+= check_loaded_objects (loaded
);
128 const char *loading
[3];
130 loading
[0] = "circlemod1a.so";
131 loading
[1] = "circlemod2a.so";
132 loading
[2] = "circlemod3a.so";
133 errors
+= load_dso (loading
, 0, RTLD_LAZY
);
134 errors
+= load_dso (loading
, 0, RTLD_NOW
);
136 loading
[0] = "circlemod1.so";
137 loading
[1] = "circlemod2.so";
138 loading
[2] = "circlemod3.so";
139 errors
+= load_dso (loading
, 1, RTLD_LAZY
);
140 errors
+= load_dso (loading
, 1, RTLD_NOW
);
143 printf ("%d errors found\n", errors
);