* elf32-spu.c (build_stub): Fix malloc under-allocation.
[binutils.git] / ld / testsuite / ld-auto-import / client.c
blobb883fdbd17b64fdc3f8c145389ce40bfdb2b7fc5
1 #include <stdio.h>
3 extern int var;
4 extern void (*func_ptr)(void);
5 extern void print_var (void);
6 extern void print_foo (void);
7 extern int foo;
8 extern int var2[2];
10 typedef struct
12 int * var;
13 void (* func_ptr)(void);
14 int * var_with_offset;
16 TEST;
18 TEST xyz = { & var, print_var, & var };
20 const TEST const_xyz = { & var, print_var, & var };
22 int
23 main (void)
25 print_var ();
27 printf ("We see var = %d\n", var);
28 printf ("Setting var = 456\n");
30 var = 456;
32 print_var ();
33 printf ("We see var = %d\n\n", var);
35 var = 90;
36 print_var ();
37 printf ("We see var = %d\n\n", var);
39 print_foo ();
40 printf ("We see foo = %d\n", foo);
41 printf ("Setting foo = 19\n");
42 foo = 19;
43 print_foo ();
44 printf ("We see foo = %d\n\n", foo);
45 fflush (stdout);
47 printf ("Calling dllimported function pointer\n");
48 func_ptr ();
50 printf ("Calling functions using global structure\n");
51 xyz.func_ptr ();
52 * xyz.var = 40;
53 xyz.func_ptr ();
55 printf ("We see var2[0] = %d\n\n", var2[0]);
57 printf ("We see const xyz %x %x\n", const_xyz.var, const_xyz.var_with_offset);
59 return 0;