OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [ld/] [testsuite/] [ld-elfvsb/] [main.c] - Blame information for rev 148

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 59 khays
#ifdef PROTECTED_CHECK
2
#include <features.h>
3
#include <stdio.h>
4
 
5
int
6
main (void)
7
{
8
#if defined (__GLIBC__) && (__GLIBC__ > 2 \
9
                            || (__GLIBC__ == 2 \
10
                                &&  __GLIBC_MINOR__ >= 2))
11
  puts ("yes");
12
#else
13
  puts ("no");
14
#endif
15
  return 0;
16
}
17
#else
18
/* This is the main program for the shared library test.  */
19
 
20
#include <stdio.h>
21
 
22
int mainvar = 1;
23
int overriddenvar = 2;
24
extern int shlibvar1;
25
 
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 ();
45
extern int shlib_visibility_checkcom ();
46
extern int shlib_visibility_checkweak ();
47
 
48
int shlib_visibility_com = 1;
49
 
50
int shlib_visibility_var_weak = 1;
51
 
52
int
53
shlib_visibility_func_weak ()
54
{
55
  return 1;
56
}
57
 
58
#ifdef HIDDEN_WEAK_TEST
59
#define WEAK_TEST
60
#endif
61
 
62
#ifdef PROTECTED_WEAK_TEST
63
#define WEAK_TEST
64
#endif
65
 
66
#ifdef PROTECTED_UNDEF_TEST
67
#define PROTECTED_TEST
68
#endif
69
 
70
#ifndef WEAK_TEST
71
extern int visibility ();
72
extern int visibility_var;
73
#endif
74
 
75
#if !defined (HIDDEN_TEST) && defined (PROTECTED_TEST)
76
int
77
visibility (void)
78
{
79
  return 1;
80
}
81
 
82
static int
83
main_visibility_check (void)
84
{
85
  return ((int (*) (void)) visibility_funptr ()) != visibility;
86
}
87
 
88
int visibility_var = 1;
89
 
90
static int
91
main_visibility_checkvar (void)
92
{
93
  return visibility_varval () != visibility_var
94
         && visibility_varptr () != &visibility_var;
95
}
96
 
97
#ifndef PROTECTED_UNDEF_TEST
98
int shared_data = 1;
99
asm (".protected shared_data");
100
 
101
int
102
shared_func (void)
103
{
104
  return 1;
105
}
106
 
107
asm (".protected shared_func");
108
 
109
extern int * shared_data_p ();
110
typedef int (*func) ();
111
extern func shared_func_p ();
112
#endif
113
#else
114
static int
115
main_visibility_check (void)
116
{
117
#ifdef WEAK_TEST
118
  return visibility_funptr () == NULL;
119
#else
120
  return ((int (*) (void)) visibility_funptr ()) == visibility;
121
#endif
122
}
123
 
124
static int
125
main_visibility_checkvar (void)
126
{
127
#ifdef WEAK_TEST
128
  return visibility_varval () == 0
129
         && visibility_varptr () == NULL;
130
#else
131
  return visibility_varval () == visibility_var
132
         && visibility_varptr () == &visibility_var;
133
#endif
134
}
135
#endif
136
 
137
/* This function is called by the shared library.  */
138
 
139
int
140
main_called (void)
141
{
142
  return 6;
143
}
144
 
145
/* This function overrides a function in the shared library.  */
146
 
147
int
148
shlib_overriddencall2 (void)
149
{
150
  return 8;
151
}
152
 
153
#ifdef HIDDEN_NORMAL_TEST
154
int visibility_com;
155
asm (".hidden visibility_com");
156
 
157
int
158
main_visibility_checkcom (void)
159
{
160
  return visibility_com == 0;
161
}
162
 
163
int
164
main_visibility_checkweak (void)
165
{
166
  return 1;
167
}
168
#elif defined (HIDDEN_WEAK_TEST)
169
int
170
main_visibility_checkcom (void)
171
{
172
  return 1;
173
}
174
 
175
#pragma weak visibility_undef_var_weak
176
extern int visibility_undef_var_weak;
177
asm (".hidden visibility_undef_var_weak");
178
 
179
#pragma weak visibility_undef_func_weak
180
extern int visibility_undef_func_weak ();
181
asm (".hidden visibility_undef_func_weak");
182
 
183
#pragma weak visibility_var_weak
184
extern int visibility_var_weak;
185
asm (".hidden visibility_var_weak");
186
 
187
#pragma weak visibility_func_weak
188
extern int visibility_func_weak ();
189
asm (".hidden visibility_func_weak");
190
 
191
int
192
main_visibility_checkweak ()
193
{
194
  return &visibility_undef_var_weak == NULL
195
         && &visibility_undef_func_weak == NULL
196
         && &visibility_func_weak == NULL
197
         && &visibility_var_weak == NULL;
198
}
199
#elif defined (HIDDEN_UNDEF_TEST)
200
extern int visibility_def;
201
asm (".hidden visibility_def");
202
extern int visibility_func ();
203
asm (".hidden visibility_func");
204
 
205
int
206
main_visibility_checkcom (void)
207
{
208
  return & visibility_def != NULL && visibility_def == 2;
209
}
210
 
211
int
212
main_visibility_checkweak (void)
213
{
214
  return & visibility_func != NULL && visibility_func () == 2;
215
}
216
#else
217
int
218
main_visibility_checkcom (void)
219
{
220
  return 1;
221
}
222
 
223
int
224
main_visibility_checkweak (void)
225
{
226
  return 1;
227
}
228
#endif
229
 
230
int
231
main (void)
232
{
233
  int (*p) ();
234
  int ret = 0;
235
 
236
  printf ("mainvar == %d\n", mainvar);
237
  printf ("overriddenvar == %d\n", overriddenvar);
238
  printf ("shlibvar1 == %d\n", shlibvar1);
239
#ifndef XCOFF_TEST
240
  printf ("shlib_mainvar () == %d\n", shlib_mainvar ());
241
  printf ("shlib_overriddenvar () == %d\n", shlib_overriddenvar ());
242
#endif
243
  printf ("shlib_shlibvar1 () == %d\n", shlib_shlibvar1 ());
244
  printf ("shlib_shlibvar2 () == %d\n", shlib_shlibvar2 ());
245
  printf ("shlib_shlibcall () == %d\n", shlib_shlibcall ());
246
#ifndef XCOFF_TEST
247
  printf ("shlib_shlibcall2 () == %d\n", shlib_shlibcall2 ());
248
  printf ("shlib_maincall () == %d\n", shlib_maincall ());
249
#endif
250
  printf ("main_called () == %d\n", main_called ());
251
  printf ("shlib_checkfunptr1 (shlib_shlibvar1) == %d\n",
252
          shlib_checkfunptr1 (shlib_shlibvar1));
253
#ifndef XCOFF_TEST
254
  printf ("shlib_checkfunptr2 (main_called) == %d\n",
255
          shlib_checkfunptr2 (main_called));
256
#endif
257
  p = shlib_getfunptr1 ();
258
  printf ("shlib_getfunptr1 () ");
259
  if (p == shlib_shlibvar1)
260
    printf ("==");
261
  else
262
    printf ("!=");
263
  printf (" shlib_shlibvar1\n");
264
#ifndef XCOFF_TEST
265
  p = shlib_getfunptr2 ();
266
  printf ("shlib_getfunptr2 () ");
267
  if (p == main_called)
268
    printf ("==");
269
  else
270
    printf ("!=");
271
  printf (" main_called\n");
272
#endif
273
  printf ("shlib_check () == %d\n", shlib_check ());
274
  printf ("visibility_check () == %d\n", visibility_check ());
275
  printf ("visibility_checkfunptr () == %d\n",
276
          visibility_checkfunptr ());
277
  printf ("main_visibility_check () == %d\n", main_visibility_check ());
278
  printf ("visibility_checkvar () == %d\n", visibility_checkvar ());
279
  printf ("visibility_checkvarptr () == %d\n",
280
          visibility_checkvarptr ());
281
  printf ("main_visibility_checkvar () == %d\n",
282
          main_visibility_checkvar ());
283
  printf ("main_visibility_checkcom () == %d\n",
284
          main_visibility_checkcom ());
285
  printf ("shlib_visibility_checkcom () == %d\n",
286
          shlib_visibility_checkcom ());
287
  printf ("main_visibility_checkweak () == %d\n",
288
          main_visibility_checkweak ());
289
  printf ("shlib_visibility_checkweak () == %d\n",
290
          shlib_visibility_checkweak ());
291
 
292
#if !defined (PROTECTED_UNDEF_TEST) && defined (PROTECTED_TEST)
293
  if (&shared_data != shared_data_p ())
294
    ret = 1;
295
  p = shared_func_p ();
296
  if (shared_func != p)
297
    ret = 1;
298
  if (shared_data != *shared_data_p ())
299
    ret = 1;
300
  if (shared_func () != (*p) () )
301
    ret = 1;
302
#endif
303
 
304
  return ret;
305
}
306
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.