9 #if defined (__GLIBC__) && (__GLIBC__ > 2 \
11 && __GLIBC_MINOR__ >= 2))
19 /* This is the main program for the shared library test. */
24 int overriddenvar
= 2;
27 extern int shlib_mainvar ();
28 extern int shlib_overriddenvar ();
29 extern int shlib_shlibvar1 ();
30 extern int shlib_shlibvar2 ();
31 extern int shlib_shlibcall ();
32 extern int shlib_maincall ();
33 extern int shlib_checkfunptr1 ();
34 extern int shlib_checkfunptr2 ();
35 extern int (*shlib_getfunptr1 ()) ();
36 extern int (*shlib_getfunptr2 ()) ();
37 extern int shlib_check ();
38 extern int shlib_shlibcall2 ();
39 extern int visibility_check ();
40 extern int visibility_checkfunptr ();
41 extern void *visibility_funptr ();
42 extern int visibility_checkvar ();
43 extern int visibility_checkvarptr ();
44 extern int visibility_varval ();
45 extern void *visibility_varptr ();
47 #ifdef HIDDEN_WEAK_TEST
51 #ifdef PROTECTED_WEAK_TEST
55 #ifdef PROTECTED_UNDEF_TEST
56 #define PROTECTED_TEST
60 extern int visibility ();
61 extern int visibility_var
;
64 #if !defined (HIDDEN_TEST) && defined (PROTECTED_TEST)
72 main_visibility_check ()
74 return visibility_funptr () != visibility
;
77 int visibility_var
= 1;
80 main_visibility_checkvar ()
82 return visibility_varval () != visibility_var
83 && visibility_varptr () != &visibility_var
;
87 main_visibility_check ()
90 return visibility_funptr () == NULL
;
92 return visibility_funptr () == visibility
;
97 main_visibility_checkvar ()
100 return visibility_varval () == 0
101 && visibility_varptr () == NULL
;
103 return visibility_varval () == visibility_var
104 && visibility_varptr () == &visibility_var
;
109 /* This function is called by the shared library. */
117 /* This function overrides a function in the shared library. */
120 shlib_overriddencall2 ()
130 printf ("mainvar == %d\n", mainvar
);
131 printf ("overriddenvar == %d\n", overriddenvar
);
132 printf ("shlibvar1 == %d\n", shlibvar1
);
134 printf ("shlib_mainvar () == %d\n", shlib_mainvar ());
135 printf ("shlib_overriddenvar () == %d\n", shlib_overriddenvar ());
137 printf ("shlib_shlibvar1 () == %d\n", shlib_shlibvar1 ());
138 printf ("shlib_shlibvar2 () == %d\n", shlib_shlibvar2 ());
139 printf ("shlib_shlibcall () == %d\n", shlib_shlibcall ());
141 printf ("shlib_shlibcall2 () == %d\n", shlib_shlibcall2 ());
142 printf ("shlib_maincall () == %d\n", shlib_maincall ());
144 printf ("main_called () == %d\n", main_called ());
145 printf ("shlib_checkfunptr1 (shlib_shlibvar1) == %d\n",
146 shlib_checkfunptr1 (shlib_shlibvar1
));
148 printf ("shlib_checkfunptr2 (main_called) == %d\n",
149 shlib_checkfunptr2 (main_called
));
151 p
= shlib_getfunptr1 ();
152 printf ("shlib_getfunptr1 () ");
153 if (p
== shlib_shlibvar1
)
157 printf (" shlib_shlibvar1\n");
159 p
= shlib_getfunptr2 ();
160 printf ("shlib_getfunptr2 () ");
161 if (p
== main_called
)
165 printf (" main_called\n");
167 printf ("shlib_check () == %d\n", shlib_check ());
168 printf ("visibility_check () == %d\n", visibility_check ());
169 printf ("visibility_checkfunptr () == %d\n",
170 visibility_checkfunptr ());
171 printf ("main_visibility_check () == %d\n", main_visibility_check ());
172 printf ("visibility_checkvar () == %d\n", visibility_checkvar ());
173 printf ("visibility_checkvarptr () == %d\n",
174 visibility_checkvarptr ());
175 printf ("main_visibility_checkvar () == %d\n",
176 main_visibility_checkvar ());