update generated files
[binutils.git] / ld / testsuite / ld-elfvsb / main.c
blob26542b8a1fcf3aeb5d12afcac1a37dbfd5cbbe02
1 #ifdef PROTECTED_CHECK
2 #include <features.h>
3 #include <stdio.h>
5 int
6 main (void)
8 #if defined (__GLIBC__) && (__GLIBC__ > 2 \
9 || (__GLIBC__ == 2 \
10 && __GLIBC_MINOR__ >= 2))
11 puts ("yes");
12 #else
13 puts ("no");
14 #endif
15 return 0;
17 #else
18 /* This is the main program for the shared library test. */
20 #include <stdio.h>
22 int mainvar = 1;
23 int overriddenvar = 2;
24 extern int shlibvar1;
26 extern int shlib_mainvar ();
27 extern int shlib_overriddenvar ();
28 extern int shlib_shlibvar1 ();
29 extern int shlib_shlibvar2 ();
30 extern int shlib_shlibcall ();
31 extern int shlib_maincall ();
32 extern int shlib_checkfunptr1 ();
33 extern int shlib_checkfunptr2 ();
34 extern int (*shlib_getfunptr1 ()) ();
35 extern int (*shlib_getfunptr2 ()) ();
36 extern int shlib_check ();
37 extern int shlib_shlibcall2 ();
38 extern int visibility_check ();
39 extern int visibility_checkfunptr ();
40 extern void *visibility_funptr ();
41 extern int visibility_checkvar ();
42 extern int visibility_checkvarptr ();
43 extern int visibility_varval ();
44 extern void *visibility_varptr ();
46 #ifdef HIDDEN_WEAK_TEST
47 #define WEAK_TEST
48 #endif
50 #ifdef PROTECTED_WEAK_TEST
51 #define WEAK_TEST
52 #endif
54 #ifdef PROTECTED_UNDEF_TEST
55 #define PROTECTED_TEST
56 #endif
58 #ifndef WEAK_TEST
59 extern int visibility ();
60 extern int visibility_var;
61 #endif
63 #if !defined (HIDDEN_TEST) && defined (PROTECTED_TEST)
64 int
65 visibility ()
67 return 1;
70 static int
71 main_visibility_check ()
73 return visibility_funptr () != visibility;
76 int visibility_var = 1;
78 static int
79 main_visibility_checkvar ()
81 return visibility_varval () != visibility_var
82 && visibility_varptr () != &visibility_var;
84 #else
85 static int
86 main_visibility_check ()
88 #ifdef WEAK_TEST
89 return visibility_funptr () == NULL;
90 #else
91 return visibility_funptr () == visibility;
92 #endif
95 static int
96 main_visibility_checkvar ()
98 #ifdef WEAK_TEST
99 return visibility_varval () == 0
100 && visibility_varptr () == NULL;
101 #else
102 return visibility_varval () == visibility_var
103 && visibility_varptr () == &visibility_var;
104 #endif
106 #endif
108 /* This function is called by the shared library. */
111 main_called ()
113 return 6;
116 /* This function overrides a function in the shared library. */
119 shlib_overriddencall2 ()
121 return 8;
125 main ()
127 int (*p) ();
129 printf ("mainvar == %d\n", mainvar);
130 printf ("overriddenvar == %d\n", overriddenvar);
131 printf ("shlibvar1 == %d\n", shlibvar1);
132 #ifndef XCOFF_TEST
133 printf ("shlib_mainvar () == %d\n", shlib_mainvar ());
134 printf ("shlib_overriddenvar () == %d\n", shlib_overriddenvar ());
135 #endif
136 printf ("shlib_shlibvar1 () == %d\n", shlib_shlibvar1 ());
137 printf ("shlib_shlibvar2 () == %d\n", shlib_shlibvar2 ());
138 printf ("shlib_shlibcall () == %d\n", shlib_shlibcall ());
139 #ifndef XCOFF_TEST
140 printf ("shlib_shlibcall2 () == %d\n", shlib_shlibcall2 ());
141 printf ("shlib_maincall () == %d\n", shlib_maincall ());
142 #endif
143 printf ("main_called () == %d\n", main_called ());
144 printf ("shlib_checkfunptr1 (shlib_shlibvar1) == %d\n",
145 shlib_checkfunptr1 (shlib_shlibvar1));
146 #ifndef XCOFF_TEST
147 printf ("shlib_checkfunptr2 (main_called) == %d\n",
148 shlib_checkfunptr2 (main_called));
149 #endif
150 p = shlib_getfunptr1 ();
151 printf ("shlib_getfunptr1 () ");
152 if (p == shlib_shlibvar1)
153 printf ("==");
154 else
155 printf ("!=");
156 printf (" shlib_shlibvar1\n");
157 #ifndef XCOFF_TEST
158 p = shlib_getfunptr2 ();
159 printf ("shlib_getfunptr2 () ");
160 if (p == main_called)
161 printf ("==");
162 else
163 printf ("!=");
164 printf (" main_called\n");
165 #endif
166 printf ("shlib_check () == %d\n", shlib_check ());
167 printf ("visibility_check () == %d\n", visibility_check ());
168 printf ("visibility_checkfunptr () == %d\n",
169 visibility_checkfunptr ());
170 printf ("main_visibility_check () == %d\n", main_visibility_check ());
171 printf ("visibility_checkvar () == %d\n", visibility_checkvar ());
172 printf ("visibility_checkvarptr () == %d\n",
173 visibility_checkvarptr ());
174 printf ("main_visibility_checkvar () == %d\n",
175 main_visibility_checkvar ());
176 return 0;
178 #endif