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)
184 #pragma weak visibility
186 extern int visibility ();
195 #ifdef HIDDEN_NORMAL_TEST
196 asm (".hidden visibility_normal");
206 visibility_checkfunptr ()
211 #ifdef HIDDEN_NORMAL_TEST
212 int (*v
) () = visibility_normal
;
214 int (*v
) () = visibility
;
225 return visibility () == 1;
229 #ifdef HIDDEN_NORMAL_TEST
230 return visibility_normal () == 2;
232 return visibility () == 2;
241 if (&visibility
== NULL
)
248 #if defined (HIDDEN_UNDEF_TEST) || defined (PROTECTED_UNDEF_TEST)
250 #pragma weak visibility_var;
252 extern int visibility_var
;
254 int visibility_var
= 2;
257 #ifdef HIDDEN_NORMAL_TEST
258 asm (".hidden visibility_var_normal");
260 int visibility_var_normal
= 2;
264 visibility_checkvarptr ()
268 return visibility_var
== 1;
272 #ifdef HIDDEN_NORMAL_TEST
273 int *v
= &visibility_var_normal
;
275 int *v
= &visibility_var
;
282 visibility_checkvar ()
287 #ifdef HIDDEN_NORMAL_TEST
288 return visibility_var_normal
== 2;
290 return visibility_var
== 2;
299 if (&visibility_var
== NULL
)
303 return &visibility_var
;
310 if (&visibility_var
== NULL
)
314 return visibility_var
;
317 #if defined (HIDDEN_TEST) || defined (HIDDEN_UNDEF_TEST)
318 asm (".hidden visibility");
319 asm (".hidden visibility_var");
321 #if defined (PROTECTED_TEST) || defined (PROTECTED_UNDEF_TEST) || defined (PROTECTED_WEAK_TEST)
322 asm (".protected visibility");
323 asm (".protected visibility_var");