aarch64: Fix f{max,min}{f} build for GCC 4.9 and 5
[glibc.git] / dlfcn / default.c
blob612ab79b1269e5bd4203d057662b57684a5b90a3
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <string.h>
6 extern int test_in_mod1 (void *);
7 extern int test_in_mod2 (void *);
10 int
11 main (int argc, char *argv[])
13 int (*ifp) (void);
14 void *p;
15 int result = 0;
16 Dl_info info;
18 dladdr(main, &info);
19 if (info.dli_fname == NULL)
21 printf ("%s: dladdr returns NULL dli_fname\n", __FILE__);
22 result = 1;
24 else if (strcmp (info.dli_fname, argv[0]))
26 printf ("%s: dladdr returned '%s' as dli_fname\n", __FILE__, info.dli_fname);
27 result = 1;
29 else
30 printf ("%s: dladdr returned correct dli_fname\n", __FILE__);
32 /* Find function `main'. */
33 p = dlsym (RTLD_DEFAULT, "main");
34 if (p == NULL)
36 printf ("%s: main not found\n", __FILE__);
37 result = 1;
39 else if ((int (*)(int, char **))p != main)
41 printf ("%s: wrong address returned for main\n", __FILE__);
42 result = 1;
44 else
45 printf ("%s: main correctly found\n", __FILE__);
47 ifp = dlsym (RTLD_DEFAULT, "found_in_mod1");
48 if ((void *) ifp == NULL)
50 printf ("%s: found_in_mod1 not found\n", __FILE__);
51 result = 1;
53 else if (ifp () != 1)
55 printf ("%s: wrong address returned for found_in_mod1\n", __FILE__);
56 result = 1;
58 else
59 printf ("%s: found_in_mod1 correctly found\n", __FILE__);
61 ifp = dlsym (RTLD_DEFAULT, "found_in_mod2");
62 if ((void *) ifp == NULL)
64 printf ("%s: found_in_mod2 not found\n", __FILE__);
65 result = 1;
67 else if (ifp () != 2)
69 printf ("%s: wrong address returned for found_in_mod2\n", __FILE__);
70 result = 1;
72 else
73 printf ("%s: found_in_mod2 correctly found\n", __FILE__);
75 result |= test_in_mod1 (main);
77 result |= test_in_mod2 (main);
79 return result;