Commit | Line | Data |
---|---|---|
83b89087 | 1 | # Expect script for binutils tests |
b90efa5b | 2 | # Copyright (C) 2009-2015 Free Software Foundation, Inc. |
83b89087 L |
3 | # |
4 | # This file is part of the GNU Binutils. | |
5 | # | |
6 | # This program is free software; you can redistribute it and/or modify | |
7 | # it under the terms of the GNU General Public License as published by | |
8 | # the Free Software Foundation; either version 3 of the License, or | |
9 | # (at your option) any later version. | |
10 | # | |
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU General Public License | |
17 | # along with this program; if not, write to the Free Software | |
18 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
19 | # MA 02110-1301, USA. | |
20 | # | |
21 | # Written by H.J. Lu (hongjiu.lu@intel.com) | |
22 | # | |
23 | ||
24 | # Make sure that binutils can correctly handle ld output in ELF with | |
25 | # STT_GNU_IFUNC symbols. | |
26 | ||
5a68afcf | 27 | if { !([istarget "i?86-*-elf*"] |
99753d9d AM |
28 | || (([istarget "i?86-*-linux*"] |
29 | || [istarget "i?86-*-gnu*"]) | |
83b89087 L |
30 | && ![istarget "*-*-*aout*"] |
31 | && ![istarget "*-*-*oldld*"]) | |
5a68afcf RM |
32 | || [istarget "i?86-*-nacl*"] |
33 | || [istarget "x86_64-*-nacl*"] | |
83b89087 L |
34 | || [istarget "x86_64-*-linux*"] |
35 | || [istarget "amd64-*-linux*"]) } { | |
36 | return | |
37 | } | |
38 | ||
39 | proc binutils_test { prog_name ld_options test } { | |
40 | global as | |
41 | global ld | |
42 | global READELF | |
43 | global objcopy | |
44 | global strip | |
45 | global srcdir | |
46 | global subdir | |
47 | global link_output | |
48 | ||
49 | eval set prog \$$prog_name | |
50 | set test_name "$prog_name $ld_options ($test)" | |
51 | ||
52 | if { ![ld_assemble $as $srcdir/$subdir/$test.s tmpdir/$test.o ] } { | |
53 | unresolved "$test_name" | |
54 | return | |
55 | } | |
56 | ||
57 | if { ![ld_simple_link $ld tmpdir/$test "$ld_options tmpdir/$test.o"] } { | |
58 | if { [string match "*not supported*" $link_output] | |
59 | || [string match "*unrecognized option*" $link_output] } { | |
60 | unsupported "$ld_options is not supported by this target" | |
61 | } else { | |
62 | unresolved "$test_name" | |
63 | } | |
64 | return | |
65 | } | |
66 | ||
67 | send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.exp\n" | |
68 | set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.exp"] | |
69 | if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { | |
70 | send_log "$got\n" | |
71 | unresolved "$test_name" | |
72 | return | |
73 | } | |
74 | ||
75 | send_log "$prog tmpdir/$test\n" | |
76 | set got [remote_exec host "$prog tmpdir/$test"] | |
77 | if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { | |
78 | send_log "$got\n" | |
79 | fail "$test_name" | |
80 | return | |
81 | } | |
82 | ||
83 | send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.out\n" | |
84 | set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"] | |
85 | if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { | |
86 | send_log "$got\n" | |
87 | unresolved "$test_name" | |
88 | return | |
89 | } | |
90 | ||
91 | if { [catch {exec cmp tmpdir/$test.exp tmpdir/$test.out}] } then { | |
92 | send_log "tmpdir/$test.exp tmpdir/$test.out differ.\n" | |
93 | fail "$test_name" | |
94 | return | |
95 | } | |
96 | ||
97 | pass "$test_name" | |
98 | } | |
99 | ||
100 | binutils_test strip "" ifunc-4-x86 | |
101 | binutils_test objcopy "" ifunc-4-x86 | |
102 | binutils_test strip "" ifunc-4-local-x86 | |
103 | binutils_test objcopy "" ifunc-4-local-x86 |