8 #if defined (__GLIBC__) && (__GLIBC__ > 2 \
10 && __GLIBC_MINOR__ >= 2))
18 /* This is the main program for the shared library test. */
23 int overriddenvar
= 2;
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
50 #ifdef PROTECTED_WEAK_TEST
54 #ifdef PROTECTED_UNDEF_TEST
55 #define PROTECTED_TEST
59 extern int visibility ();
60 extern int visibility_var
;
63 #if !defined (HIDDEN_TEST) && defined (PROTECTED_TEST)
71 main_visibility_check ()
73 return visibility_funptr () != visibility
;
76 int visibility_var
= 1;
79 main_visibility_checkvar ()
81 return visibility_varval () != visibility_var
82 && visibility_varptr () != &visibility_var
;
86 main_visibility_check ()
89 return visibility_funptr () == NULL
;
91 return visibility_funptr () == visibility
;
96 main_visibility_checkvar ()
99 return visibility_varval () == 0
100 && visibility_varptr () == NULL
;
102 return visibility_varval () == visibility_var
103 && visibility_varptr () == &visibility_var
;
108 /* This function is called by the shared library. */
116 /* This function overrides a function in the shared library. */
119 shlib_overriddencall2 ()
129 printf ("mainvar == %d\n", mainvar
);
130 printf ("overriddenvar == %d\n", overriddenvar
);
131 printf ("shlibvar1 == %d\n", shlibvar1
);
133 printf ("shlib_mainvar () == %d\n", shlib_mainvar ());
134 printf ("shlib_overriddenvar () == %d\n", shlib_overriddenvar ());
136 printf ("shlib_shlibvar1 () == %d\n", shlib_shlibvar1 ());
137 printf ("shlib_shlibvar2 () == %d\n", shlib_shlibvar2 ());
138 printf ("shlib_shlibcall () == %d\n", shlib_shlibcall ());
140 printf ("shlib_shlibcall2 () == %d\n", shlib_shlibcall2 ());
141 printf ("shlib_maincall () == %d\n", shlib_maincall ());
143 printf ("main_called () == %d\n", main_called ());
144 printf ("shlib_checkfunptr1 (shlib_shlibvar1) == %d\n",
145 shlib_checkfunptr1 (shlib_shlibvar1
));
147 printf ("shlib_checkfunptr2 (main_called) == %d\n",
148 shlib_checkfunptr2 (main_called
));
150 p
= shlib_getfunptr1 ();
151 printf ("shlib_getfunptr1 () ");
152 if (p
== shlib_shlibvar1
)
156 printf (" shlib_shlibvar1\n");
158 p
= shlib_getfunptr2 ();
159 printf ("shlib_getfunptr2 () ");
160 if (p
== main_called
)
164 printf (" main_called\n");
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 ());