]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-ifunc/binutils.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-ifunc / binutils.exp
1 # Expect script for binutils tests
2 # Copyright (C) 2009-2021 Free Software Foundation, Inc.
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
27 if { !([istarget "i?86-*-elf*"]
28 || [istarget "i?86-*-linux*"]
29 || [istarget "i?86-*-gnu*"]
30 || [istarget "x86_64-*-linux*"]
31 || [istarget "amd64-*-linux*"]) } {
32 return
33 }
34
35 proc binutils_test { prog_name ld_options test } {
36 global as
37 global ld
38 global READELF
39 global objcopy
40 global strip
41 global srcdir
42 global subdir
43 global link_output
44
45 eval set prog \$$prog_name
46 set test_name "$prog_name $ld_options ($test)"
47
48 if { ![ld_assemble $as $srcdir/$subdir/$test.s tmpdir/$test.o ] } {
49 unresolved "$test_name"
50 return
51 }
52
53 if { ![ld_link $ld tmpdir/$test "$ld_options tmpdir/$test.o"] } {
54 if { [string match "*not supported*" $link_output]
55 || [string match "*unrecognized option*" $link_output] } {
56 unsupported "$ld_options is not supported by this target"
57 } else {
58 unresolved "$test_name"
59 }
60 return
61 }
62
63 send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.exp\n"
64 set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.exp"]
65 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
66 send_log "$got\n"
67 unresolved "$test_name"
68 return
69 }
70
71 send_log "$prog tmpdir/$test\n"
72 set got [remote_exec host "$prog tmpdir/$test"]
73 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
74 send_log "$got\n"
75 fail "$test_name"
76 return
77 }
78
79 send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.out\n"
80 set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
81 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
82 send_log "$got\n"
83 unresolved "$test_name"
84 return
85 }
86
87 if { [catch {exec cmp tmpdir/$test.exp tmpdir/$test.out}] } then {
88 send_log "tmpdir/$test.exp tmpdir/$test.out differ.\n"
89 fail "$test_name"
90 return
91 }
92
93 pass "$test_name"
94 }
95
96 binutils_test strip "" ifunc-4-x86
97 binutils_test objcopy "" ifunc-4-x86
98 binutils_test strip "" ifunc-4-local-x86
99 binutils_test objcopy "" ifunc-4-local-x86