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
# Skip target where -shared is not supported
31
if ![check_shared_lib_support] {
35
# Check if compiler works
36
if { [which $CC] == 0 } {
40
# Some bare-metal targets don't support shared libs or PIC.
41
if { ![run_host_cmd_yesno $CC "-shared -fPIC $srcdir/$subdir/dummy.c -o tmpdir/t.so"] } {
45
proc check_link_message { cmd string testname } {
48
catch "exec $cmd" exec_output
49
send_log "$exec_output\n"
50
verbose "$exec_output"
53
if [string match "*$str*" $exec_output] {
54
pass "$testname: $str"
56
fail "$testname: $str"
61
if { ![ld_compile $CC $srcdir/$subdir/indirect1a.c tmpdir/indirect1a.o]
62
|| ![ld_compile $CC $srcdir/$subdir/indirect1b.c tmpdir/indirect1b.o]
63
|| ![ld_compile "$CC -fPIC" $srcdir/$subdir/indirect2.c tmpdir/indirect2.o]
64
|| ![ld_compile $CC $srcdir/$subdir/indirect3a.c tmpdir/indirect3a.o]
65
|| ![ld_compile $CC $srcdir/$subdir/indirect3b.c tmpdir/indirect3b.o]
66
|| ![ld_compile $CC $srcdir/$subdir/indirect4a.c tmpdir/indirect4a.o]
67
|| ![ld_compile $CC $srcdir/$subdir/indirect4b.c tmpdir/indirect4b.o] } {
68
unresolved "Indirect symbol tests"
73
{"Build libindirect1c.so"
75
{indirect1c.c} {} "libindirect1c.so"}
76
{"Build libindirect3c.so"
78
{indirect3c.c} {} "libindirect3c.so"}
79
{"Build libindirect4c.so"
81
{indirect4c.c} {} "libindirect4c.so"}
84
run_cc_link_tests $build_tests
88
set string ": final link failed: Bad value"
89
set string1 ": local symbol \`foo\' in tmpdir/indirect1b.o is referenced by DSO"
91
set testname "Indirect symbol 1a"
92
set cmd "$ld -e start -o tmpdir/indirect1 tmpdir/indirect1a.o tmpdir/indirect1b.o tmpdir/libindirect1c.so"
93
check_link_message "$cmd" [list $string1 $string] "$testname"
95
set testname "Indirect symbol 1b"
96
set cmd "$ld -e start -o tmpdir/indirect1 tmpdir/indirect1a.o tmpdir/libindirect1c.so tmpdir/indirect1b.o"
97
check_link_message "$cmd" [list $string1 $string] "$testname"
99
set string ": final link failed: Nonrepresentable section on output"
100
set string2 ": No symbol version section for versioned symbol \`foo@FOO\'"
101
set testname "Indirect symbol 2"
102
set cmd "$ld -shared -o tmpdir/indirect2.so tmpdir/indirect2.o"
103
check_link_message "$cmd" [list $string2 $string] "$testname"
105
# The following tests require running the executable generated by ld.
111
{"Run with libindirect3c.so 1"
112
"tmpdir/indirect3a.o tmpdir/indirect3b.o tmpdir/libindirect3c.so" ""
113
{dummy.c} "indirect3a" "indirect3.out"}
114
{"Run with libindirect3c.so 2"
115
"tmpdir/indirect3a.o tmpdir/libindirect3c.so tmpdir/indirect3b.o" ""
116
{dummy.c} "indirect3b" "indirect3.out"}
117
{"Run with libindirect3c.so 3"
118
"tmpdir/indirect3b.o tmpdir/libindirect3c.so tmpdir/indirect3a.o" ""
119
{dummy.c} "indirect3c" "indirect3.out"}
120
{"Run with libindirect3c.so 4"
121
"tmpdir/libindirect3c.so tmpdir/indirect3b.o tmpdir/indirect3a.o" ""
122
{dummy.c} "indirect3d" "indirect3.out"}
123
{"Run with libindirect4c.so 1"
124
"tmpdir/indirect4a.o tmpdir/indirect4b.o tmpdir/libindirect4c.so" ""
125
{dummy.c} "indirect4a" "indirect4.out"}
126
{"Run with libindirect4c.so 2"
127
"tmpdir/indirect4a.o tmpdir/libindirect4c.so tmpdir/indirect4b.o" ""
128
{dummy.c} "indirect4b" "indirect4.out"}
129
{"Run with libindirect4c.so 3"
130
"tmpdir/indirect4b.o tmpdir/libindirect4c.so tmpdir/indirect4a.o" ""
131
{dummy.c} "indirect4c" "indirect4.out"}
132
{"Run with libindirect4c.so 4"
133
"tmpdir/libindirect4c.so tmpdir/indirect4b.o tmpdir/indirect4a.o" ""
134
{dummy.c} "indirect4d" "indirect4.out"}
137
run_ld_link_exec_tests [] $run_tests