1 # Expect script for various indirect symbol tests.
2 # Copyright 2012 Free Software Foundation, Inc.
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.
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.
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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
20 # Written by H.J. Lu (hongjiu.lu@intel.com)
23 # Exclude non-ELF targets.
29 # Check if compiler works
30 if { [which $CC] == 0 } {
34 proc check_link_message { cmd string testname } {
37 catch "exec $cmd" exec_output
38 send_log "$exec_output\n"
39 verbose "$exec_output"
42 if [string match "*$str*" $exec_output] {
43 pass "$testname: $str"
45 fail "$testname: $str"
50 if { ![ld_compile $CC $srcdir/$subdir/indirect1a.c tmpdir/indirect1a.o]
51 || ![ld_compile $CC $srcdir/$subdir/indirect1b.c tmpdir/indirect1b.o]
52 || ![ld_compile "$CC -fPIC" $srcdir/$subdir/indirect2.c tmpdir/indirect2.o]
53 || ![ld_compile $CC $srcdir/$subdir/indirect3a.c tmpdir/indirect3a.o]
54 || ![ld_compile $CC $srcdir/$subdir/indirect3b.c tmpdir/indirect3b.o]
55 || ![ld_compile $CC $srcdir/$subdir/indirect4a.c tmpdir/indirect4a.o]
56 || ![ld_compile $CC $srcdir/$subdir/indirect4b.c tmpdir/indirect4b.o] } {
57 unresolved "Indirect symbol tests"
62 {"Build libindirect1c.so"
64 {indirect1c.c} {} "libindirect1c.so"}
65 {"Build libindirect3c.so"
67 {indirect3c.c} {} "libindirect3c.so"}
68 {"Build libindirect4c.so"
70 {indirect4c.c} {} "libindirect4c.so"}
73 run_cc_link_tests $build_tests
77 set string ": final link failed: Bad value"
78 set string1 ": local symbol \`foo\' in tmpdir/indirect1b.o is referenced by DSO"
80 set testname "Indirect symbol 1a"
81 set cmd "$ld -e start -o tmpdir/indirect1 tmpdir/indirect1a.o tmpdir/indirect1b.o tmpdir/libindirect1c.so"
82 check_link_message "$cmd" [list $string1 $string] "$testname"
84 set testname "Indirect symbol 1b"
85 set cmd "$ld -e start -o tmpdir/indirect1 tmpdir/indirect1a.o tmpdir/libindirect1c.so tmpdir/indirect1b.o"
86 check_link_message "$cmd" [list $string1 $string] "$testname"
88 set string ": final link failed: Nonrepresentable section on output"
89 set string2 ": No symbol version section for versioned symbol \`foo@FOO\'"
90 set testname "Indirect symbol 2"
91 set cmd "$ld -shared -o tmpdir/indirect2.so tmpdir/indirect2.o"
92 check_link_message "$cmd" [list $string2 $string] "$testname"
94 # The following tests require running the executable generated by ld.
100 {"Run with libindirect3c.so 1"
101 "tmpdir/indirect3a.o tmpdir/indirect3b.o tmpdir/libindirect3c.so" ""
102 {dummy.c} "indirect3a" "indirect3.out"}
103 {"Run with libindirect3c.so 2"
104 "tmpdir/indirect3a.o tmpdir/libindirect3c.so tmpdir/indirect3b.o" ""
105 {dummy.c} "indirect3b" "indirect3.out"}
106 {"Run with libindirect3c.so 3"
107 "tmpdir/indirect3b.o tmpdir/libindirect3c.so tmpdir/indirect3a.o" ""
108 {dummy.c} "indirect3c" "indirect3.out"}
109 {"Run with libindirect3c.so 4"
110 "tmpdir/libindirect3c.so tmpdir/indirect3b.o tmpdir/indirect3a.o" ""
111 {dummy.c} "indirect3d" "indirect3.out"}
112 {"Run with libindirect4c.so 1"
113 "tmpdir/indirect4a.o tmpdir/indirect4b.o tmpdir/libindirect4c.so" ""
114 {dummy.c} "indirect4a" "indirect4.out"}
115 {"Run with libindirect4c.so 2"
116 "tmpdir/indirect4a.o tmpdir/libindirect4c.so tmpdir/indirect4b.o" ""
117 {dummy.c} "indirect4b" "indirect4.out"}
118 {"Run with libindirect4c.so 3"
119 "tmpdir/indirect4b.o tmpdir/libindirect4c.so tmpdir/indirect4a.o" ""
120 {dummy.c} "indirect4c" "indirect4.out"}
121 {"Run with libindirect4c.so 4"
122 "tmpdir/libindirect4c.so tmpdir/indirect4b.o tmpdir/indirect4a.o" ""
123 {dummy.c} "indirect4d" "indirect4.out"}
126 run_ld_link_exec_tests [] $run_tests