This commit was generated by cvs2svn to track changes on a CVS vendor
[external/binutils.git] / ld / testsuite / ld-elfvers / vers1.c
1 /*
2  * Basic test of versioning.  The idea with this is that we define
3  * a bunch of definitions of the same symbol, and we can theoretically
4  * then link applications against varying sets of these.
5  */
6 const char * show_bar1 = "asdf";
7 const char * show_bar2 = "asdf";
8
9 extern int new2_foo();
10 extern int bar33();
11
12 int
13 bar()
14 {
15         return 3;
16 }
17
18 /*
19  * The 'hide' prefix is something so that we can automatically search the
20  * symbol table and verify that none of these symbols were actually exported.
21  */
22 int
23 hide_original_foo()
24 {
25         return 1+bar();
26
27 }
28
29 int
30 hide_old_foo()
31 {
32         return 10+bar();
33
34 }
35
36 int
37 hide_old_foo1()
38 {
39         return 100+bar();
40
41 }
42
43 int
44 hide_new_foo()
45 {
46         return 1000+bar();
47
48 }
49
50 __asm__(".symver hide_original_foo,show_foo@");
51 __asm__(".symver hide_old_foo,show_foo@VERS_1.1");
52 __asm__(".symver hide_old_foo1,show_foo@VERS_1.2");
53 __asm__(".symver hide_new_foo,show_foo@@VERS_2.0");
54
55
56
57 #ifdef DO_TEST10
58 /* In test 10, we try and define a non-existant version node.  The linker
59  * should catch this and complain. */
60 int
61 hide_new_bogus_foo()
62 {
63         return 1000+bar();
64
65 }
66 __asm__(".symver hide_new_bogus_foo,show_foo@VERS_2.2");
67 #endif
68
69
70
71
72 #ifdef DO_TEST11
73 /*
74  * This test is designed to catch a couple of syntactic errors.  The assembler
75  * should complain about both of the directives below.
76  */
77 void
78 xyzzz()
79 {
80   new2_foo();
81   bar33();
82 }
83
84 __asm__(".symver new2_foo,fooVERS_2.0");
85 __asm__(".symver bar33,bar@@VERS_2.0");
86 #endif
87
88 #ifdef DO_TEST12
89 /*
90  * This test is designed to catch a couple of syntactic errors.  The assembler
91  * should complain about both of the directives below.
92  */
93 void
94 xyzzz()
95 {
96   new2_foo();
97   bar33();
98 }
99
100 __asm__(".symver bar33,bar@@VERS_2.0");
101 #endif