This commit was generated by cvs2svn to track changes on a CVS vendor
[external/binutils.git] / ld / testsuite / ld-elfvers / vers.exp
1 # Expect script for ld-version tests
2 #   Copyright (C) 1997, 1998, 1999 Free Software Foundation
3 #
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 #
18 # Written by Eric Youngdale (eric@andante.jic.com)
19
20 #
21
22 # This test can only be run if ld generates native executables.
23 if ![isnative] then {return}
24
25 # This test can only be run on a couple of ELF platforms.
26 # Square bracket expressions seem to confuse istarget.
27 # This is similar to the test that is used in ld-shared, BTW.
28 if { ![istarget i?86-*-sysv4*] \
29      && ![istarget i?86-*-unixware] \
30      && ![istarget i?86-*-elf*] \
31      && ![istarget i?86-*-linux*] \
32      && ![istarget m68k-*-linux*] \
33      && ![istarget mips*-*-irix5*] \
34      && ![istarget powerpc-*-elf*] \
35      && ![istarget powerpc-*-linux*] \
36      && ![istarget powerpc-*-sysv4*] \
37      && ![istarget sparc*-*-elf] \
38      && ![istarget sparc*-*-solaris2*] \
39      && ![istarget sparc*-*-linux*] \
40      && ![istarget alpha*-*-linux*] } {
41     return
42 }
43
44 if { [istarget i?86-*-linuxaout*] \
45      || [istarget i?86-*-linuxoldld*] \
46      || [istarget m68k-*-linuxaout*] } {
47     return
48 }
49
50 if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
51     return
52 }
53
54 set diff diff
55 set tmpdir tmpdir
56 set VOBJDUMP_FLAGS --private-headers
57 set DOBJDUMP_FLAGS --dynamic-syms
58 set SOBJDUMP_FLAGS --syms
59 set shared --shared
60 set script --version-script
61
62 proc test_ar { test lib object expect } {
63     global ar
64     global nm
65     global tmpdir
66     global srcdir
67     global subdir
68     global diff
69
70     verbose -log "$ar -cr $tmpdir/$lib $tmpdir/$object"
71     catch "exec $ar -cr $tmpdir/$lib $tmpdir/$object" exec_output
72     set exec_output [prune_warnings $exec_output]
73     if ![string match "" $exec_output] {
74         verbose -log "$exec_output"
75         unresolved "$test"
76         return
77     }
78     
79     verbose -log "$nm --print-armap $tmpdir/$lib | grep \" in \" | egrep \"VERS\\|bar\\|foo\" | sort > $tmpdir/nm.out"
80
81     catch "exec $nm --print-armap $tmpdir/$lib | grep \\\ in\\\  | egrep VERS\\\|bar\\\|foo | sort > $tmpdir/nm.out" exec_output
82     if [string match "" $exec_output] then {
83         catch "exec $diff -q $tmpdir/nm.out $srcdir/$subdir/$expect" exec_output
84         set exec_output [prune_warnings $exec_output]
85         if [string match "" $exec_output] then {
86             pass $test
87             return
88         } else {
89             verbose -log "$exec_output"
90             fail "$test"
91             return
92         }
93     } else {
94         verbose -log "$exec_output"
95         fail "$test"
96     }
97 }
98
99 #
100 # objdump_emptysymstuff
101 #       Check non-dynamic symbols and make sure there are none with '@'.
102 #
103 proc objdump_emptysymstuff { objdump object } {
104     global SOBJDUMP_FLAGS
105     global version_output
106     global diff
107
108     if ![info exists SOBJDUMP_FLAGS] { set SOBJDUMP_FLAGS "" }
109
110     verbose -log "$objdump $SOBJDUMP_FLAGS $object | sed -n /\@/p"
111
112     catch "exec $objdump $SOBJDUMP_FLAGS $object | sed -n /\@/p" exec_output
113     set exec_output [prune_warnings $exec_output]
114     if [string match "" $exec_output] then {
115 # We shouldn't get anything here.
116         return 1
117     } else {
118 # it is not normal to come here - we have no output to compare.
119         verbose -log "$exec_output"
120         verbose -log "objdump_emptysymstuff: did not expect any output from objdump"
121         return 0
122     }
123
124 }
125
126 #
127 # objdump_emptydynsymstuff
128 #       Check dynamic symbols and make sure there are none with '@'.
129 #
130 proc objdump_emptydynsymstuff { objdump object } {
131     global DOBJDUMP_FLAGS
132     global version_output
133     global diff
134
135     if ![info exists VOBJDUMP_FLAGS] { set VOBJDUMP_FLAGS "" }
136
137     verbose -log "$objdump $DOBJDUMP_FLAGS $object | sed -n /VERS/p\\\;/show/p"
138
139     catch "exec $objdump $DOBJDUMP_FLAGS $object | sed -n /VERS/p\\\;/show/p" exec_output
140     set exec_output [prune_warnings $exec_output]
141     if [string match "" $exec_output] then {
142 # We shouldn't get anything here.
143         return 1
144     } else { if [string match "*objdump: *: not a dynamic object" $exec_output] then {
145         return 1
146     } else {
147 # it is not normal to come here - we have no output to compare.
148         verbose -log "$exec_output"
149         verbose -log "objdump_emptydynsymstuff: did not expect any output from objdump"
150         return 0
151     } }
152 }
153
154 #
155 # objdump_emptyverstuff
156 #       Make sure there is no version information
157 #
158 proc objdump_emptyverstuff { objdump object } {
159     global VOBJDUMP_FLAGS
160     global version_output
161     global diff
162     global tmpdir
163
164     if {[which $objdump] == 0} then {
165         perror "$objdump does not exist"
166         return 0
167     }
168
169     if ![info exists VOBJDUMP_FLAGS] { set VOBJDUMP_FLAGS "" }
170
171     verbose -log "$objdump $VOBJDUMP_FLAGS $object | sed -n /Version/,\\\$p > $tmpdir/objdump.out"
172
173     catch "exec $objdump $VOBJDUMP_FLAGS $object | sed -n /Version/,\\\$p" exec_output
174     set exec_output [prune_warnings $exec_output]
175     if [string match "" $exec_output] then {
176 # it is normal to fail here - we have no output to compare.
177         return 1
178     } else { if { [string match "*libc*" $exec_output] } then {
179 # this probably means that there is version information in libc, so we
180 # can't really perform this test.
181         return 1
182     } else {
183         verbose -log "$exec_output"
184         verbose -log "objdump_emptyverstuff: did not expect any output from objdump"
185         return 0
186     } }
187
188 }
189
190 #
191 # objdump_symstuff
192 #       Dump non-dynamic symbol stuff and make sure that it is sane.
193 #
194 proc objdump_symstuff { objdump object expectfile } {
195     global SOBJDUMP_FLAGS
196     global version_output
197     global diff
198     global tmpdir
199
200     if ![info exists SOBJDUMP_FLAGS] { set SOBJDUMP_FLAGS "" }
201
202     verbose -log "$objdump $SOBJDUMP_FLAGS $object | grep \@ | sort  > $tmpdir/objdump.out"
203
204     catch "exec $objdump $SOBJDUMP_FLAGS $object | grep \@ | sort  > $tmpdir/objdump.out" exec_output
205     set exec_output [prune_warnings $exec_output]
206     if [string match "" $exec_output] then {
207
208 # Now do a line-by-line comparison to effectively diff the darned things
209 # The stuff coming from the expectfile is actually a regex, so we can
210 # skip over the actual addresses and so forth.  This is currently very
211 # simpleminded - it expects a one-to-one correspondence in terms of line
212 # numbers.
213
214         if [file exists $expectfile] then {
215             set file_a [open $expectfile r]
216         } else {
217             perror "$expectfile doesn't exist"
218             return 0
219         }
220         
221         if [file exists $tmpdir/objdump.out] then {
222             set file_b [open $tmpdir/objdump.out r]
223         } else {
224             perror "$tmpdir/objdump.out doesn't exist"
225             return 0
226         }
227
228         verbose "# Diff'ing: $expectfile $tmpdir/objdump.out" 2
229
230         set eof -1
231         set differences 0
232
233         while { [gets $file_a line] != $eof } {
234             if [regexp "^#.*$" $line] then {
235                 continue
236             } else {
237                 lappend list_a $line
238             }
239         }
240         close $file_a
241
242         while { [gets $file_b line] != $eof } {
243             if [regexp "^#.*$" $line] then {
244                 continue
245             } else {
246                 lappend list_b $line
247             }
248         }
249         close $file_b
250         
251         for { set i 0 } { $i < [llength $list_a] } { incr i } {
252             set line_a [lindex $list_a $i]
253             set line_b [lindex $list_b $i]
254             
255
256             verbose "\t$expectfile: $i: $line_a" 3
257             verbose "\t/tmp/objdump.out: $i: $line_b" 3
258             if [regexp $line_a $line_b] then {
259                 continue
260             } else {
261                 verbose -log "\t$expectfile: $i: $line_a"
262                 verbose -log "\t$tmpdir/objdump.out: $i: $line_b"
263                 
264                 return 0
265             }
266         }
267         
268         if { [llength $list_a] != [llength $list_b] } {
269             verbose -log "Line count"
270             return 0
271         }
272         
273         if $differences<1 then {
274             return 1
275         }
276         
277         return 0
278     } else {
279         verbose -log "$exec_output"
280         return 0
281     }
282
283 }
284
285 #
286 # objdump_dymsymstuff
287 #       Dump dynamic symbol stuff and make sure that it is sane.
288 #
289 proc objdump_dynsymstuff { objdump object expectfile } {
290     global DOBJDUMP_FLAGS
291     global version_output
292     global diff
293     global tmpdir
294
295     if ![info exists DOBJDUMP_FLAGS] { set DOBJDUMP_FLAGS "" }
296
297     verbose -log "$objdump $DOBJDUMP_FLAGS $object | sed -n /VERS/p\\\;/show/p | sort | uniq  > $tmpdir/objdump.out"
298
299     catch "exec $objdump $DOBJDUMP_FLAGS $object | sed -n /VERS/p\\\;/show/p | sort | uniq  > $tmpdir/objdump.out" exec_output
300     set exec_output [prune_warnings $exec_output]
301     if [string match "" $exec_output] then {
302
303 # Now do a line-by-line comparison to effectively diff the darned things
304 # The stuff coming from the expectfile is actually a regex, so we can
305 # skip over the actual addresses and so forth.  This is currently very
306 # simpleminded - it expects a one-to-one correspondence in terms of line
307 # numbers.
308
309         if [file exists $expectfile] then {
310             set file_a [open $expectfile r]
311         } else {
312             warning "$expectfile doesn't exist"
313             return 0
314         }
315         
316         if [file exists $tmpdir/objdump.out] then {
317             set file_b [open $tmpdir/objdump.out r]
318         } else {
319             fail "$tmpdir/objdump.out doesn't exist"
320             return 0
321         }
322
323         verbose "# Diff'ing: $expectfile $tmpdir/objdump.out" 2
324
325         set eof -1
326         set differences 0
327
328         while { [gets $file_a line] != $eof } {
329             if [regexp "^#.*$" $line] then {
330                 continue
331             } else {
332                 lappend list_a $line
333             }
334         }
335         close $file_a
336
337         while { [gets $file_b line] != $eof } {
338             if [regexp "^#.*$" $line] then {
339                 continue
340             } else {
341                 lappend list_b $line
342             }
343         }
344         close $file_b
345         
346         for { set i 0 } { $i < [llength $list_b] } { incr i } {
347             set line_b [lindex $list_b $i]
348             
349 # The tests are rigged so that we should never export a symbol with the
350 # word 'hide' in it.  Thus we just search for it, and bail if we find it.
351             if [regexp "hide" $line_b] then {
352                 verbose -log "\t$tmpdir/objdump.out: $i: $line_b"
353                 
354                 return 0
355             }
356
357             verbose "\t$expectfile: $i: $line_b" 3
358
359             # We can't assume that the sort is consistent across
360             # systems, so we must check each regexp.  When we find a
361             # regexp, we null it out, so we don't match it twice.
362             for { set j 0 } { $j < [llength $list_a] } { incr j } {
363                 set line_a [lindex $list_a $j]
364
365                 if [regexp $line_a $line_b] then {
366                     lreplace $list_a $j $j "CAN NOT MATCH"
367                     break
368                 }
369             }
370
371             if { $j >= [llength $list_a] } {
372                 verbose -log "\t$tmpdir/objdump.out: $i: $line_b"
373                 
374                 return 0
375             }
376         }
377         
378         if { [llength $list_a] != [llength $list_b] } {
379             verbose -log "Line count"
380             return 0
381         }
382         
383         if $differences<1 then {
384             return 1
385         }
386         
387         return 0
388     } else {
389         verbose -log "$exec_output"
390         return 0
391     }
392
393 }
394
395 #
396 # objdump_versionstuff
397 #       Dump version definitions/references and make sure that it is sane.
398 #
399 proc objdump_versionstuff { objdump object expectfile } {
400     global VOBJDUMP_FLAGS
401     global version_output
402     global diff
403     global tmpdir
404
405     if {[which $objdump] == 0} then {
406         perror "$objdump does not exist"
407         return 0
408     }
409
410     if ![info exists VOBJDUMP_FLAGS] { set VOBJDUMP_FLAGS "" }
411
412     verbose -log "$objdump $VOBJDUMP_FLAGS $object | sed -n /Version/,\\\$p > $tmpdir/objdump.out"
413
414     catch "exec $objdump $VOBJDUMP_FLAGS $object | sed -n /Version/,\\\$p > $tmpdir/objdump.out" exec_output
415     set exec_output [prune_warnings $exec_output]
416     if [string match "" $exec_output] then {
417
418         # It's OK if there are extra lines in the actual output; they
419         # may come from version information in libc.  We require that
420         # every line in EXPECTFILE appear in the output in order.
421
422         set f1 [open $tmpdir/objdump.out r]
423         set f2 [open $expectfile r]
424         gets $f2 l2
425         while { [gets $f1 l1] != -1 } {
426             if { [string match $l2 $l1] } then {
427                 if { [gets $f2 l2] == -1 } then {
428                     close $f1
429                     close $f2
430                     return 1
431                 }
432             }
433         }
434
435         # We reached the end of the output without seeing the line we
436         # expected.  This is a test failure.
437
438         close $f1
439         close $f2
440
441         verbose -log "Did not find \"$l2\""
442         set f1 [open $tmpdir/objdump.out r]
443         while { [gets $f1 l1] != -1 } {
444             verbose -log $l1
445         }
446
447         verbose -log "$exec_output"
448         return 0
449     } else {
450         verbose -log "$exec_output"
451         return 0
452     }
453 }
454
455 proc build_vers_lib { test source libname other mapfile verexp versymexp symexp } {
456     global ld
457     global srcdir
458     global subdir
459     global exec_output
460     global host_triplet
461     global tmpdir
462     global as
463     global objdump
464     global CC
465     global CFLAGS
466     global shared
467     global script
468
469     if ![ld_compile "$CC -S $CFLAGS" $srcdir/$subdir/$source $tmpdir/$libname.s]     {
470         unresolved "$test"
471         return
472     }
473
474     if ![ld_assemble $as $tmpdir/$libname.s $tmpdir/$libname.o ]     {
475         unresolved "$test"
476         return
477     }
478
479     if [string match "" $other] then {
480         set other_lib ""
481     } else {
482         set other_lib $tmpdir/$other
483     }
484
485     if [string match "" $mapfile] then {
486         set script_arg ""
487     } else {
488         set script_arg "$script $srcdir/$subdir/$mapfile"
489     }
490
491     if {![ld_simple_link $ld $tmpdir/$libname.so "$shared $tmpdir/$libname.o $other_lib $script_arg"]}     {
492         fail "$test"
493         return
494     }
495
496     if {![objdump_versionstuff $objdump $tmpdir/$libname.so $srcdir/$subdir/$verexp ]}     {
497         fail "$test"
498         return
499     }
500
501     if {![objdump_dynsymstuff $objdump $tmpdir/$libname.so $srcdir/$subdir/$versymexp ]}     {
502         fail "$test"
503         return
504     }
505
506     if [string match "" $symexp] then {
507         if {![objdump_emptysymstuff $objdump $tmpdir/$libname.o ]}     {
508             fail "$test"
509             return
510         }
511     } else {
512         if {![objdump_symstuff $objdump $tmpdir/$libname.o $srcdir/$subdir/$symexp ]}     {
513             fail "$test"
514             return
515         }
516     }
517
518     pass $test
519     
520 }
521
522 proc test_ldfail { test flag source execname other mapfile whyfail } {
523     global ld
524     global srcdir
525     global subdir
526     global exec_output
527     global host_triplet
528     global tmpdir
529     global as
530     global objdump
531     global CC
532     global CFLAGS
533     global script
534
535     if [string match "" $other] then {
536         set other_lib ""
537     } else {
538         set other_lib $tmpdir/$other
539     }
540
541     if ![ld_compile "$CC -S $flag $CFLAGS" $srcdir/$subdir/$source $tmpdir/$execname.s]     {
542         unresolved "$test"
543         return
544     }
545
546     if ![ld_assemble $as $tmpdir/$execname.s $tmpdir/$execname.o ]     {
547         unresolved "$test"
548         return
549     }
550
551     verbose -log "This link should fail because of $whyfail"
552
553     if [string match "" $mapfile] then {
554         set script_arg ""
555     } else {
556         set script_arg "$script $srcdir/$subdir/$mapfile"
557     }
558
559     if {![ld_link $ld $tmpdir/$execname "$tmpdir/$execname.o $other_lib $script_arg"]}     {
560         pass "$test"
561         return
562     }
563     fail "$test"
564 }
565
566 proc test_asfail { test flag source execname whyfail } {
567     global srcdir
568     global subdir
569     global tmpdir
570     global as
571     global CC
572     global CFLAGS
573
574     if ![ld_compile "$CC -S $flag $CFLAGS" $srcdir/$subdir/$source $tmpdir/$execname.s]     {
575         unresolved "$test"
576         return
577     }
578
579     verbose -log "This assemble should fail because of $whyfail"
580     catch "exec $as -o $tmpdir/$execname.o $tmpdir/$execname.s" exec_output
581     set exec_output [prune_warnings $exec_output]
582     if [string match "" $exec_output] then {
583         fail "$test"
584         return
585     }
586     verbose -log "$exec_output"
587     pass "$test"
588 }
589
590 proc test_strip_vers_lib { test srclib libname verexp versymexp } {
591     global strip
592     global srcdir
593     global subdir
594     global exec_output
595     global host_triplet
596     global tmpdir
597     global objdump
598
599     verbose -log "cp $tmpdir/$srclib $tmpdir/$libname.so"
600     exec cp $tmpdir/$srclib $tmpdir/$libname.so
601
602     verbose -log "$strip $tmpdir/$libname.so"
603     catch "exec $strip $tmpdir/$libname.so" exec_output
604     if [string match "" $exec_output] then {
605
606 # If strip went OK, then run the usual tests on the thing to make sure that
607 # it is sane.
608         if {![objdump_versionstuff $objdump $tmpdir/$libname.so $srcdir/$subdir/$verexp ]}     {
609             fail "$test"
610             return
611         }
612         
613         if {![objdump_dynsymstuff $objdump $tmpdir/$libname.so $srcdir/$subdir/$versymexp ]}     {
614             fail "$test"
615             return
616         }
617         
618     } else {
619         verbose -log "$exec_output"
620         fail "$test"
621         return
622     }
623     pass $test
624 }
625
626
627 proc build_exec { test source execname flags solibname verexp versymexp symexp } {
628     global ld
629     global srcdir
630     global subdir
631     global exec_output
632     global host_triplet
633     global tmpdir
634     global as
635     global objdump
636     global CC
637     global CFLAGS
638
639     set shared --shared
640     set script --version-script
641     if ![ld_compile "$CC -S $CFLAGS" $srcdir/$subdir/$source $tmpdir/$execname.s]     {
642         unresolved "$test"
643         return
644     }
645
646     if ![ld_assemble $as $tmpdir/$execname.s $tmpdir/$execname.o ]     {
647         unresolved "$test"
648         return
649     }
650
651     if [string match "" $solibname] then {
652         set solibname_lib ""
653     } else {
654         set solibname_lib $tmpdir/$solibname
655     }
656
657     if {![ld_link $ld $tmpdir/$execname "$flags $tmpdir/$execname.o $solibname_lib"]}     {
658         fail "$test"
659         return
660     }
661
662     if [string match "" $verexp] then {
663 #
664 # Make sure we get nothing back.
665 #
666         if {![objdump_emptyverstuff $objdump $tmpdir/$execname ]}     {
667             fail "$test"
668             return
669         }
670     } else {
671         if {![objdump_versionstuff $objdump $tmpdir/$execname $srcdir/$subdir/$verexp ]}     {
672             fail "$test"
673             return
674         }
675     }
676
677     if [string match "" $versymexp] then {
678         if {![objdump_emptydynsymstuff $objdump $tmpdir/$execname ]}     {
679             fail "$test"
680             return
681         }
682     } else {
683         if {![objdump_dynsymstuff $objdump $tmpdir/$execname $srcdir/$subdir/$versymexp ]}     {
684             fail "$test"
685             return
686         }
687     }
688
689     if [string match "" $symexp] then {
690         if {![objdump_emptysymstuff $objdump $tmpdir/$execname.o ]}     {
691             fail "$test"
692             return
693         }
694     } else {
695         if {![objdump_symstuff $objdump $tmpdir/$execname.o $srcdir/$subdir/$symexp ]}     {
696             fail "$test"
697             return
698         }
699     }
700
701     pass $test
702 }
703
704
705 #
706 # Basic test - build a library with versioned symbols.
707 #
708 build_vers_lib "vers1" vers1.c vers1 "" vers1.map vers1.ver vers1.dsym vers1.sym
709
710
711 #
712 # Test #2 - build a library, and link it against the library we built in step
713 # 1.
714 #
715 build_vers_lib "vers2" vers2.c vers2 vers1.so vers2.map vers2.ver vers2.dsym ""
716
717 #
718 # Test #3 - build an executable, and link it against vers1.so.
719 #
720 build_exec "vers3" vers3.c vers3 "" vers1.so vers3.ver vers3.dsym ""
721
722 #
723 # Test #4 - Make sure a version implicitly defined in an executable
724 # causes a version node to be created.  Verify this both with and without
725 # --export-dynamic.
726 #
727
728 # This test fails on MIPS.  On the MIPS we must put foo in the dynamic
729 # symbol table, which the test does not expect.
730 setup_xfail "mips*-*-*"
731 build_exec "vers4" vers4.c vers4 "" "" "" "" vers4.sym
732
733 build_exec "vers4a" vers4.c vers4a "-export-dynamic" "" vers4a.ver vers4a.dsym vers4a.sym
734
735
736 #
737 # Try multiple definitions foo@BAR and foo@@BAR and make sure the linker
738 # complains.
739 #
740 test_ldfail "vers5" "" vers5.c vers5 "" "" "multiple definition of foo@VERS_1.2"
741
742 #
743 #
744 # Now build a test that should reference a bunch of versioned symbols.
745 # All of them should be correctly referenced.
746 #
747 build_exec "vers6" vers6.c vers6 "" vers1.so vers6.ver vers6.dsym vers6.sym
748
749 #
750 # Another test to verify that something made local via 'local' is truly not
751 # accessible.
752 #
753 build_vers_lib "vers7a" vers7a.c vers7a "" vers7.map vers7a.ver vers7a.dsym vers7a.sym
754
755 test_ldfail "vers7" "" vers7.c vers7 vers7a.so "" "undefined reference to hide_a"
756
757
758 #
759 # This test is designed to verify that we can pass a linker script on the
760 # command line as if it were a normal .o file.
761 #
762 catch "exec cp $srcdir/$subdir/vers8.map $tmpdir/" ignore_output
763 build_vers_lib "vers8" vers1.c vers8 vers8.map "" vers8.ver vers1.dsym vers1.sym
764
765 #
766 # This test tries to make sure that version references to versioned symbols
767 # don't collide with default definitions with the same symbol.
768 #
769 build_exec "vers9" vers9.c vers9 "-export-dynamic" "" vers9.ver vers9.dsym vers9.sym
770
771
772 #
773 # Try and use a non-existant version node.  The linker should fail with
774 # an error message.
775 #
776 test_ldfail "vers10" "-DDO_TEST10" vers1.c vers10 "" "vers1.map --shared" "invalid version"
777
778 #
779 # Try and some things the assembler should complain about.
780 #
781 test_asfail "vers11" "-DDO_TEST11" vers1.c vers11 "no @ in symver"
782
783 test_asfail "vers12" "-DDO_TEST12" vers1.c vers12 "extern version definition"
784
785 #
786 # Put a shared library in an archive library, and make sure the global
787 # archive symbol table is sane.
788 #
789 test_ar "ar with versioned solib" vers13.a vers1.so vers13.asym
790
791 #
792 # Strip a shared library, and make sure we didn't screw something up in there.
793 #
794 test_strip_vers_lib "vers14" vers1.so vers14 vers1.ver vers1.dsym 
795
796
797 #
798 # Build another test with some versioned symbols.  Here we are going to 
799 # try and override something from the library, and we shouldn't get
800 # any errors.
801 #
802 build_exec "vers15" vers15.c vers15 "" vers1.so vers15.ver vers15.dsym vers15.sym
803
804 #
805 # Test that when we override a versioned symbol from the library this
806 # symbol appears in the dynamic symbol table of the executable.
807 #
808 build_vers_lib "vers16a" vers16a.c vers16a "" vers16.map vers16a.ver vers16a.dsym ""
809 build_exec "vers16" vers16.c vers16 "" vers16a.so "" vers16.dsym ""
810
811 # Test a weak versioned symbol.
812 build_vers_lib "vers17" vers17.c vers17 "" vers17.map vers17.ver vers17.dsym ""
813 build_vers_lib "vers18" vers18.c vers18 vers17.so vers18.map vers18.ver vers18.dsym vers18.sym
814 build_exec "vers19" vers19.c vers19 "-rpath ." vers18.so vers19.ver vers19.dsym ""