Remove Linux kernel version ambiguity in comment added by previous commit.
[platform/upstream/glibc.git] / dlfcn / default.c
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <string.h>
4
5
6 extern int test_in_mod1 (void *);
7 extern int test_in_mod2 (void *);
8
9
10 int
11 main (int argc, char *argv[])
12 {
13   int (*ifp) (void);
14   void *p;
15   int result = 0;
16   Dl_info info;
17
18   dladdr(main, &info);
19   if (info.dli_fname == NULL)
20     {
21       printf ("%s: dladdr returns NULL dli_fname\n", __FILE__);
22       result = 1;
23     }
24   else if (strcmp (info.dli_fname, argv[0]))
25     {
26       printf ("%s: dladdr returned '%s' as dli_fname\n", __FILE__, info.dli_fname);
27       result = 1;
28     }
29   else
30     printf ("%s: dladdr returned correct dli_fname\n", __FILE__);
31
32   /* Find function `main'.  */
33   p = dlsym (RTLD_DEFAULT, "main");
34   if (p == NULL)
35     {
36       printf ("%s: main not found\n", __FILE__);
37       result = 1;
38     }
39   else if ((int (*)(int, char **))p != main)
40     {
41       printf ("%s: wrong address returned for main\n", __FILE__);
42       result = 1;
43     }
44   else
45     printf ("%s: main correctly found\n", __FILE__);
46
47   ifp = dlsym (RTLD_DEFAULT, "found_in_mod1");
48   if ((void *) ifp == NULL)
49     {
50       printf ("%s: found_in_mod1 not found\n", __FILE__);
51       result = 1;
52     }
53   else if (ifp () != 1)
54     {
55       printf ("%s: wrong address returned for found_in_mod1\n", __FILE__);
56       result = 1;
57     }
58   else
59     printf ("%s: found_in_mod1 correctly found\n", __FILE__);
60
61   ifp = dlsym (RTLD_DEFAULT, "found_in_mod2");
62   if ((void *) ifp == NULL)
63     {
64       printf ("%s: found_in_mod2 not found\n", __FILE__);
65       result = 1;
66     }
67   else if (ifp () != 2)
68     {
69       printf ("%s: wrong address returned for found_in_mod2\n", __FILE__);
70       result = 1;
71     }
72   else
73     printf ("%s: found_in_mod2 correctly found\n", __FILE__);
74
75   result |= test_in_mod1 (main);
76
77   result |= test_in_mod2 (main);
78
79   return result;
80 }