Automatic date update in version.in
[binutils-gdb.git] / ld / testsuite / ld-x86-64 / no-plt.exp
blob088ecf7d0d9fb2955a88ac9600d96507fbe10dac
1 # Expect script for x86-64 no-PLT tests.
2 # Copyright (C) 2016-2024 Free Software Foundation, Inc.
4 # This file is part of the GNU Binutils.
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.
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.
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.
22 # The following tests require running the executable generated by ld,
23 # or enough of a build environment to create a fully linked executable.
24 # This is not commonly available when testing a cross-built linker.
25 if ![isnative] {
26 return
29 if ![is_elf_format] {
30 return
33 if ![istarget "x86_64-*-*"] {
34 return
37 # Check to see if the C compiler works
38 if { ![check_compiler_available] } {
39 return
42 run_cc_link_tests [list \
43 [list \
44 "Build no-plt-func1.o no-plt-main1.o" \
45 "" \
46 "-fPIE -Wa,-mx86-used-note=yes" \
47 {no-plt-func1.c no-plt-main1.c} \
48 ] \
49 [list \
50 "Build no-plt-check1.o no-plt-extern1.o" \
51 "" \
52 "-Wa,-mrelax-relocations=yes,-mx86-used-note=yes" \
53 {no-plt-check1.S no-plt-extern1.S} \
54 ] \
55 [list \
56 "Build libno-plt-1a.so" \
57 "-shared tmpdir/no-plt-func1.o" \
58 "-Wa,-mx86-used-note=yes" \
59 {dummy.s} \
60 {} \
61 "libno-plt-1a.so" \
62 ] \
63 [list \
64 "Build libno-plt-1b.so" \
65 "-shared tmpdir/no-plt-extern1.o" \
66 "-Wa,-mx86-used-note=yes" \
67 {dummy.s} \
68 {{readelf -Wr libno-plt-1b.rd} \
69 {objdump -dwrj.text libno-plt-1b.dd}} \
70 "libno-plt-1b.so" \
71 ] \
72 [list \
73 "No PLT (dynamic 1a)" \
74 "$NOPIE_LDFLAGS tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
75 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
76 "-Wa,-mx86-used-note=yes" \
77 {dummy.s} \
78 {{readelf -Wr no-plt-1a.rd} {objdump -dwrj.text no-plt-1a.dd}} \
79 "no-plt-1a" \
80 ] \
81 [list \
82 "No PLT (dynamic 1b)" \
83 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
84 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
85 "-Wa,-mx86-used-note=yes" \
86 {dummy.s} \
87 {{readelf -Wr no-plt-1b.rd} {objdump -dwrj.text no-plt-1b.dd}} \
88 "no-plt-1b" \
89 ] \
90 [list \
91 "No PLT (dynamic 1c)" \
92 "$NOPIE_LDFLAGS tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
93 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
94 "-Wa,-mx86-used-note=yes" \
95 {dummy.s} \
96 {{readelf -Wr no-plt-1c.rd} {objdump -dwrj.text no-plt-1c.dd}} \
97 "no-plt-1c" \
98 ] \
99 [list \
100 "No PLT (static 1d)" \
101 "-static tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
102 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
103 "-Wa,-mx86-used-note=yes" \
104 {dummy.s} \
105 {{readelf -Wr no-plt-1d.rd} {objdump -dwrj.text no-plt-1d.dd}} \
106 "no-plt-1d" \
108 [list \
109 "No PLT (PIE 1e)" \
110 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
111 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
112 "-Wa,-mx86-used-note=yes" \
113 {dummy.s} \
114 {{readelf -Wr no-plt-1e.rd} {nm -gD no-plt-1e.nd} {objdump -dwrj.text no-plt-1e.dd}} \
115 "no-plt-1e" \
117 [list \
118 "No PLT (PIE 1f)" \
119 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
120 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
121 "-Wa,-mx86-used-note=yes" \
122 { dummy.s } \
123 {{readelf -Wr no-plt-1f.rd} {objdump -dwrj.text no-plt-1f.dd}} \
124 "no-plt-1f" \
126 [list \
127 "No PLT (PIE 1g)" \
128 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
129 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
130 "-Wa,-mx86-used-note=yes" \
131 { dummy.s } \
132 {{readelf -Wr no-plt-1g.rd} {objdump -dwrj.text no-plt-1g.dd}} \
133 "no-plt-1g" \
137 run_ld_link_exec_tests [list \
138 [list \
139 "No PLT (dynamic 1a)" \
140 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
141 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
142 "-Wa,-mx86-used-note=yes" \
143 { dummy.s } \
144 "no-plt-1a" \
145 "pass.out" \
147 [list \
148 "No PLT (dynamic 1b)" \
149 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
150 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
151 "-Wa,-mx86-used-note=yes" \
152 { dummy.s } \
153 "no-plt-1b" \
154 "pass.out" \
156 [list \
157 "No PLT (dynamic 1c)" \
158 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
159 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
160 "-Wa,-mx86-used-note=yes" \
161 { dummy.s } \
162 "no-plt-1c" \
163 "pass.out" \
165 [list \
166 "No PLT (static 1d)" \
167 "-static tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
168 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
169 "-Wa,-mx86-used-note=yes" \
170 { dummy.s } \
171 "no-plt-1d" \
172 "pass.out" \
174 [list \
175 "No PLT (PIE 1e)" \
176 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
177 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
178 "-Wa,-mx86-used-note=yes" \
179 { dummy.s } \
180 "no-plt-1e" \
181 "pass.out" \
183 [list \
184 "No PLT (PIE 1f)" \
185 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
186 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
187 "-Wa,-mx86-used-note=yes" \
188 { dummy.s } \
189 "no-plt-1f" \
190 "pass.out" \
192 [list \
193 "No PLT (PIE 1g)" \
194 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
195 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
196 "-Wa,-mx86-used-note=yes" \
197 { dummy.s } \
198 "no-plt-1g" \
199 "pass.out" \
203 # Run-time tests which require working IFUNC support.
204 if { [check_ifunc_available] } {
205 run_cc_link_tests [list \
206 [list \
207 "Build pr20253-2a.o pr20253-2b.o pr20253-2c.o pr20253-2d.o" \
208 "" \
209 "-fPIE -O2 -g -Wa,-mx86-used-note=yes" \
210 { pr20253-2a.c pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
212 [list \
213 "Build libpr20253-2a.so" \
214 "-shared tmpdir/pr20253-2b.o \
215 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
216 "-Wa,-mx86-used-note=yes" \
217 { dummy.s } \
218 {} \
219 "libpr20253-2a.so" \
223 run_ld_link_exec_tests [list \
224 [list \
225 "Run pr20253-2a" \
226 "tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \
227 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
228 "-Wa,-mx86-used-note=yes" \
229 { dummy.s } \
230 "pr20253-2a" \
231 "pass.out" \
233 [list \
234 "Run pr20253-2b" \
235 "--static tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \
236 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
237 "-Wa,-mx86-used-note=yes" \
238 { dummy.s } \
239 "pr20253-2b" \
240 "pass.out" \
242 [list \
243 "Run pr20253-2c" \
244 "-pie tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \
245 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
246 "-Wa,-mx86-used-note=yes" \
247 { dummy.s } \
248 "pr20253-2c" \
249 "pass.out" \
251 [list \
252 "Run pr20253-2d" \
253 "tmpdir/pr20253-2a.o tmpdir/libpr20253-2a.so" \
254 "-Wa,-mx86-used-note=yes" \
255 { dummy.s } \
256 "pr20253-2d" \
257 "pass.out" \
259 [list \
260 "Run pr20253-2e" \
261 "-pie tmpdir/pr20253-2a.o tmpdir/libpr20253-2a.so" \
262 "-Wa,-mx86-used-note=yes" \
263 { dummy.s } \
264 "pr20253-2e" \
265 "pass.out" \
267 [list \
268 "Run pr20253-2f" \
269 "$NOPIE_LDFLAGS tmpdir/pr20253-2a.o" \
270 "-Wa,-mx86-used-note=yes" \
271 { pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
272 "pr20253-2f" \
273 "pass.out" \
274 "-DCHECK_PLT" \
276 [list \
277 "Run pr20253-2g" \
278 "--static tmpdir/pr20253-2a.o" \
279 "-Wa,-mx86-used-note=yes" \
280 { pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
281 "pr20253-2g" \
282 "pass.out" \
283 "-DCHECK_PLT" \