Fix hypot handling of subnormals (bug 16316, bug 16330).
[glibc.git] / elf / circleload1.c
blob990ff84a848b6e34f73074fa609c1fa177eeab38
1 #include <dlfcn.h>
2 #include <libintl.h>
3 #include <link.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
8 #define MAPS ((struct link_map *) _r_debug.r_map)
10 static int
11 check_loaded_objects (const char **loaded)
13 struct link_map *lm;
14 int n;
15 int *found = NULL;
16 int errors = 0;
18 for (n = 0; loaded[n]; n++)
19 /* NOTHING */;
21 if (n)
23 found = (int *) alloca (sizeof (int) * n);
24 memset (found, 0, sizeof (int) * n);
27 printf(" Name\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)
35 int match = 0;
36 for (n = 0; loaded[n] != NULL; n++)
38 if (strcmp (basename (loaded[n]), basename (lm->l_name)) == 0)
40 found[n] = 1;
41 match = 1;
42 break;
46 if (match == 0)
48 ++errors;
49 printf ("ERRORS: %s is not unloaded\n", lm->l_name);
54 for (n = 0; loaded[n] != NULL; n++)
56 if (found[n] == 0)
58 ++errors;
59 printf ("ERRORS: %s is not loaded\n", loaded[n]);
63 return errors;
66 static int
67 load_dso (const char **loading, int undef, int flag)
69 void *obj;
70 const char *loaded[] = { NULL, NULL, NULL, NULL };
71 int errors = 0;
72 const char *errstring;
74 printf ("\nThis is what is in memory now:\n");
75 errors += check_loaded_objects (loaded);
77 printf ("Loading shared object %s: %s\n", loading[0],
78 flag == RTLD_LAZY ? "RTLD_LAZY" : "RTLD_NOW");
79 obj = dlopen (loading[0], flag);
80 if (obj == NULL)
82 if (flag == RTLD_LAZY)
84 ++errors;
85 printf ("ERRORS: dlopen shouldn't fail for RTLD_LAZY\n");
88 errstring = dlerror ();
89 if (strstr (errstring, "undefined symbol") == 0
90 || strstr (errstring, "circlemod2_undefined") == 0)
92 ++errors;
93 printf ("ERRORS: dlopen: `%s': Invalid error string\n",
94 errstring);
96 else
97 printf ("dlopen: %s\n", errstring);
99 else
101 if (undef && flag == RTLD_NOW)
103 ++errors;
104 printf ("ERRORS: dlopen shouldn't work for RTLD_NOW\n");
107 if (!undef)
109 int (*func) (void);
111 func = dlsym (obj, "circlemod1");
112 if (func == NULL)
114 ++errors;
115 printf ("ERRORS: cannot get address of \"circlemod1\": %s\n",
116 dlerror ());
118 else if (func () != 3)
120 ++errors;
121 printf ("ERRORS: function \"circlemod1\" returned wrong result\n");
125 loaded[0] = loading[0];
126 loaded[1] = loading[1];
127 loaded[2] = loading[2];
129 errors += check_loaded_objects (loaded);
131 if (obj)
133 printf ("UnLoading shared object %s\n", loading[0]);
134 dlclose (obj);
135 loaded[0] = NULL;
136 loaded[1] = NULL;
137 loaded[2] = NULL;
138 errors += check_loaded_objects (loaded);
141 return errors;
145 main (void)
147 int errors = 0;
148 const char *loading[3];
150 loading[0] = "circlemod1a.so";
151 loading[1] = "circlemod2a.so";
152 loading[2] = "circlemod3a.so";
153 errors += load_dso (loading, 0, RTLD_LAZY);
154 errors += load_dso (loading, 0, RTLD_NOW);
156 loading[0] = "circlemod1.so";
157 loading[1] = "circlemod2.so";
158 loading[2] = "circlemod3.so";
159 errors += load_dso (loading, 1, RTLD_LAZY);
160 errors += load_dso (loading, 1, RTLD_NOW);
162 if (errors != 0)
163 printf ("%d errors found\n", errors);
165 return errors;