Remove dead code in bfd_check_format_matches
[binutils-gdb.git] / ld / testsuite / ld-shared / sh1.c
blob9acb29e22dcc98cde5e6d03649674e4c7d4962a4
1 /* This is part of the shared library ld test. This file becomes part
2 of a shared library. */
4 /* This variable is supplied by the main program. */
5 extern int mainvar;
7 /* This variable is defined in the shared library, and overridden by
8 the main program. */
9 #ifndef XCOFF_TEST
10 int overriddenvar = -1;
11 #endif
13 /* This variable is defined in the shared library. */
14 int shlibvar1 = 3;
16 /* This variable is defined by another object in the shared library. */
17 extern int shlibvar2;
19 /* These functions return the values of the above variables as seen in
20 the shared library. */
22 int
23 shlib_mainvar ()
25 return mainvar;
28 #ifndef XCOFF_TEST
29 int
30 shlib_overriddenvar ()
32 return overriddenvar;
34 #endif
36 int
37 shlib_shlibvar1 ()
39 return shlibvar1;
42 int
43 shlib_shlibvar2 ()
45 return shlibvar2;
48 /* This function calls a function defined by another object in the
49 shared library. */
51 extern int shlib_shlibcalled ();
53 int
54 shlib_shlibcall ()
56 return shlib_shlibcalled ();
59 #ifndef XCOFF_TEST
60 /* This function calls a function defined in this object in the shared
61 library. The main program will override the called function. */
63 extern int shlib_overriddencall2 ();
65 int
66 shlib_shlibcall2 ()
68 return shlib_overriddencall2 ();
70 #endif
72 /* This function calls a function defined by the main program. */
74 extern int main_called ();
76 int
77 shlib_maincall ()
79 return main_called ();
82 /* This function is passed a function pointer to shlib_mainvar. It
83 confirms that the pointer compares equally. */
85 int
86 shlib_checkfunptr1 (p)
87 int (*p) ();
89 return p == shlib_shlibvar1;
92 /* This function is passed a function pointer to main_called. It
93 confirms that the pointer compares equally. */
95 int
96 shlib_checkfunptr2 (p)
97 int (*p) ();
99 return p == main_called;
102 /* This function returns a pointer to shlib_mainvar. */
105 (*shlib_getfunptr1 ()) ()
107 return shlib_shlibvar1;
110 /* This function returns a pointer to main_called. */
113 (*shlib_getfunptr2 ()) ()
115 return main_called;
118 /* This function makes sure that constant data and local functions
119 work. */
121 #ifndef __STDC__
122 #define const
123 #endif
125 static int i = 6;
126 static const char *str = "Hello, world\n";
129 shlib_check ()
131 const char *s1, *s2;
133 if (i != 6)
134 return 0;
136 /* To isolate the test, don't rely on any external functions, such
137 as strcmp. */
138 s1 = "Hello, world\n";
139 s2 = str;
140 while (*s1 != '\0')
141 if (*s1++ != *s2++)
142 return 0;
143 if (*s2 != '\0')
144 return 0;
146 if (shlib_shlibvar1 () != 3)
147 return 0;
149 return 1;