Commit | Line | Data |
---|---|---|
241e64e3 | 1 | # Expect script for simple native Linux/x86 tests. |
b3adc24a | 2 | # Copyright (C) 2018-2020 Free Software Foundation, Inc. |
241e64e3 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 | ||
74e10d17 L |
22 | # Linux/x86 tests. |
23 | if { ![istarget "i?86-*-linux*"] \ | |
24 | && ![istarget "x86_64-*-linux*"] \ | |
25 | && ![istarget "amd64-*-linux*"] } { | |
26 | return | |
27 | } | |
28 | ||
29 | run_ld_link_tests [list \ | |
30 | [list \ | |
31 | "Build pr24920.so" \ | |
32 | "-shared" \ | |
33 | "" \ | |
34 | "" \ | |
35 | {dummy.s} \ | |
36 | {} \ | |
37 | "pr24920.so" \ | |
38 | ] \ | |
39 | [list \ | |
40 | "Build pr24920" \ | |
41 | "-static " \ | |
42 | "-Bdynamic tmpdir/pr24920.so" \ | |
43 | "" \ | |
44 | {start.s} \ | |
45 | {{ld pr24920.err}} \ | |
46 | "pr24920" \ | |
47 | ] \ | |
48 | ] | |
49 | ||
241e64e3 | 50 | # Test very simple native Linux/x86 programs with linux-x86.S. |
74e10d17 | 51 | if { ![isnative] || ![check_compiler_available] } { |
241e64e3 L |
52 | return |
53 | } | |
54 | ||
55 | # Add $PLT_CFLAGS if PLT is expected. | |
56 | global PLT_CFLAGS | |
57 | # Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required. | |
58 | global NOPIE_CFLAGS NOPIE_LDFLAGS | |
59 | ||
60 | run_ld_link_exec_tests [list \ | |
61 | [list \ | |
62 | "Run PR ld/23428 test" \ | |
63 | "--no-dynamic-linker -z separate-code" \ | |
64 | "" \ | |
ab9e3428 | 65 | { linux-x86.S pr23428.c dummy.s } \ |
241e64e3 L |
66 | "pr23428" \ |
67 | "pass.out" \ | |
68 | "$NOPIE_CFLAGS -fno-asynchronous-unwind-tables" \ | |
69 | "asm" \ | |
70 | ] \ | |
71 | ] | |
8a6b075b L |
72 | |
73 | run_ld_link_tests [list \ | |
74 | [list \ | |
75 | "Build x86-feature-1" \ | |
76 | "-z separate-code -z shstk" \ | |
77 | "" \ | |
78 | "-mx86-used-note=yes" \ | |
79 | { start.s } \ | |
80 | {{readelf -n x86-feature-1a.rd}} \ | |
81 | "x86-feature-1" \ | |
82 | ] \ | |
83 | ] | |
84 | ||
85 | proc elfedit_test { options test output } { | |
86 | global ELFEDIT | |
87 | global READELF | |
88 | global srcdir | |
89 | global subdir | |
90 | ||
91 | set test_name "elfedit $options" | |
92 | send_log "$ELFEDIT $options tmpdir/$test\n" | |
93 | set got [remote_exec host "$ELFEDIT $options tmpdir/$test" "" "/dev/null"] | |
94 | if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { | |
95 | send_log "$got\n" | |
96 | unresolved "$test_name" | |
97 | } | |
98 | send_log "$READELF -n $options tmpdir/$test > tmpdir/$output.out\n" | |
99 | set got [remote_exec host "$READELF -n tmpdir/$test" "" "/dev/null" "tmpdir/$output.out"] | |
100 | if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { | |
101 | send_log "$got\n" | |
102 | unresolved "$test_name" | |
103 | } | |
104 | if { [regexp_diff tmpdir/$output.out $srcdir/$subdir/$output.rd] } then { | |
105 | fail "$test_name" | |
106 | } else { | |
107 | pass "$test_name" | |
108 | } | |
109 | } | |
110 | ||
111 | elfedit_test "--enable-x86-feature ibt --disable-x86-feature shstk" \ | |
112 | x86-feature-1 x86-feature-1b | |
113 | elfedit_test "--enable-x86-feature ibt" x86-feature-1 x86-feature-1b | |
114 | elfedit_test "--disable-x86-feature shstk" x86-feature-1 x86-feature-1c | |
115 | elfedit_test "--disable-x86-feature ibt" x86-feature-1 x86-feature-1d | |
116 | elfedit_test "--enable-x86-feature ibt --enable-x86-feature shstk" \ | |
117 | x86-feature-1 x86-feature-1e |