2 #define NULL ((void *) 0)
5 /* This is part of the shared library ld test. This file becomes part
6 of a shared library. */
8 /* This variable is supplied by the main program. */
13 /* This variable is defined in the shared library, and overridden by
16 int overriddenvar
= -1;
19 /* This variable is defined in the shared library. */
22 /* This variable is defined by another object in the shared library. */
25 /* These functions return the values of the above variables as seen in
26 the shared library. */
38 shlib_overriddenvar ()
56 /* This function calls a function defined by another object in the
59 extern int shlib_shlibcalled ();
64 return shlib_shlibcalled ();
68 /* This function calls a function defined in this object in the shared
69 library. The main program will override the called function. */
71 extern int shlib_overriddencall2 ();
76 return shlib_overriddencall2 ();
80 shlib_overriddencall2 ()
86 /* This function calls a function defined by the main program. */
89 extern int main_called ();
94 return main_called ();
98 /* This function is passed a function pointer to shlib_mainvar. It
99 confirms that the pointer compares equally. */
102 shlib_checkfunptr1 (p
)
105 return p
== shlib_shlibvar1
;
108 /* This function is passed a function pointer to main_called. It
109 confirms that the pointer compares equally. */
113 shlib_checkfunptr2 (p
)
116 return p
== main_called
;
120 /* This function returns a pointer to shlib_mainvar. */
123 (*shlib_getfunptr1 ()) ()
125 return shlib_shlibvar1
;
128 /* This function returns a pointer to main_called. */
132 (*shlib_getfunptr2 ()) ()
138 /* This function makes sure that constant data and local functions
146 static const char *str
= "Hello, world\n";
156 /* To isolate the test, don't rely on any external functions, such
158 s1
= "Hello, world\n";
166 if (shlib_shlibvar1 () != 3)
172 #ifdef HIDDEN_WEAK_TEST
173 #define HIDDEN_UNDEF_TEST
177 #ifdef PROTECTED_WEAK_TEST
178 #define PROTECTED_UNDEF_TEST
182 #if defined (HIDDEN_UNDEF_TEST) || defined (PROTECTED_UNDEF_TEST)
183 extern int visibility ();
192 #ifdef HIDDEN_NORMAL_TEST
193 asm (".hidden visibility_normal");
203 visibility_checkfunptr ()
208 #ifdef HIDDEN_NORMAL_TEST
209 int (*v
) () = visibility_normal
;
211 int (*v
) () = visibility
;
222 return visibility () == 1;
226 #ifdef HIDDEN_NORMAL_TEST
227 return visibility_normal () == 2;
229 return visibility () == 2;
238 if (&visibility
== NULL
)
245 #if defined (HIDDEN_UNDEF_TEST) || defined (PROTECTED_UNDEF_TEST)
246 extern int visibility_var
;
248 int visibility_var
= 2;
251 #ifdef HIDDEN_NORMAL_TEST
252 asm (".hidden visibility_var_normal");
254 int visibility_var_normal
= 2;
258 visibility_checkvarptr ()
262 return visibility_var
== 1;
266 #ifdef HIDDEN_NORMAL_TEST
267 int *v
= &visibility_var_normal
;
269 int *v
= &visibility_var
;
276 visibility_checkvar ()
281 #ifdef HIDDEN_NORMAL_TEST
282 return visibility_var_normal
== 2;
284 return visibility_var
== 2;
293 if (&visibility_var
== NULL
)
297 return &visibility_var
;
304 if (&visibility_var
== NULL
)
308 return visibility_var
;
311 #if defined (HIDDEN_TEST) || defined (HIDDEN_UNDEF_TEST)
312 asm (".hidden visibility");
313 asm (".hidden visibility_var");
315 #if defined (PROTECTED_TEST) || defined (PROTECTED_UNDEF_TEST) || defined (PROTECTED_WEAK_TEST)
316 asm (".protected visibility");
317 asm (".protected visibility_var");
322 asm (".weak visibility");
323 asm (".weak visibility_var");