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