]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-elf/linux-x86.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-elf / linux-x86.exp
1 # Expect script for simple native Linux/x86 tests.
2 # Copyright (C) 2018-2019 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
22 # Test very simple native Linux/x86 programs with linux-x86.S.
23 if { ![isnative] || [which $CC] == 0 \
24 || (![istarget "i?86-*-linux*"] \
25 && ![istarget "x86_64-*-linux*"] \
26 && ![istarget "amd64-*-linux*"]) } {
27 return
28 }
29
30 # Add $PLT_CFLAGS if PLT is expected.
31 global PLT_CFLAGS
32 # Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
33 global NOPIE_CFLAGS NOPIE_LDFLAGS
34
35 run_ld_link_exec_tests [list \
36 [list \
37 "Run PR ld/23428 test" \
38 "--no-dynamic-linker -z separate-code" \
39 "" \
40 { linux-x86.S pr23428.c dummy.s } \
41 "pr23428" \
42 "pass.out" \
43 "$NOPIE_CFLAGS -fno-asynchronous-unwind-tables" \
44 "asm" \
45 ] \
46 ]
47
48 run_ld_link_tests [list \
49 [list \
50 "Build x86-feature-1" \
51 "-z separate-code -z shstk" \
52 "" \
53 "-mx86-used-note=yes" \
54 { start.s } \
55 {{readelf -n x86-feature-1a.rd}} \
56 "x86-feature-1" \
57 ] \
58 ]
59
60 proc elfedit_test { options test output } {
61 global ELFEDIT
62 global READELF
63 global srcdir
64 global subdir
65
66 set test_name "elfedit $options"
67 send_log "$ELFEDIT $options tmpdir/$test\n"
68 set got [remote_exec host "$ELFEDIT $options tmpdir/$test" "" "/dev/null"]
69 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
70 send_log "$got\n"
71 unresolved "$test_name"
72 }
73 send_log "$READELF -n $options tmpdir/$test > tmpdir/$output.out\n"
74 set got [remote_exec host "$READELF -n tmpdir/$test" "" "/dev/null" "tmpdir/$output.out"]
75 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
76 send_log "$got\n"
77 unresolved "$test_name"
78 }
79 if { [regexp_diff tmpdir/$output.out $srcdir/$subdir/$output.rd] } then {
80 fail "$test_name"
81 } else {
82 pass "$test_name"
83 }
84 }
85
86 elfedit_test "--enable-x86-feature ibt --disable-x86-feature shstk" \
87 x86-feature-1 x86-feature-1b
88 elfedit_test "--enable-x86-feature ibt" x86-feature-1 x86-feature-1b
89 elfedit_test "--disable-x86-feature shstk" x86-feature-1 x86-feature-1c
90 elfedit_test "--disable-x86-feature ibt" x86-feature-1 x86-feature-1d
91 elfedit_test "--enable-x86-feature ibt --enable-x86-feature shstk" \
92 x86-feature-1 x86-feature-1e