1 # Expect script for x86-64 no-PLT tests.
2 # Copyright (C) 2016-2019 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,
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.
33 if ![istarget "x86_64-*-*"] {
37 # Check to see if the C compiler works
38 if { ![check_compiler_available] } {
42 # Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
43 global NOPIE_CFLAGS NOPIE_LDFLAGS
45 run_cc_link_tests [list \
47 "Build no-plt-func1.o no-plt-main1.o" \
49 "-fPIE -Wa,-mx86-used-note=yes" \
50 {no-plt-func1.c no-plt-main1.c} \
53 "Build no-plt-check1.o no-plt-extern1.o" \
55 "-Wa,-mrelax-relocations=yes,-mx86-used-note=yes" \
56 {no-plt-check1.S no-plt-extern1.S} \
59 "Build libno-plt-1a.so" \
60 "-shared tmpdir/no-plt-func1.o" \
61 "-Wa,-mx86-used-note=yes" \
67 "Build libno-plt-1b.so" \
68 "-shared tmpdir/no-plt-extern1.o" \
69 "-Wa,-mx86-used-note=yes" \
71 {{readelf -Wr libno-plt-1b.rd} \
72 {objdump -dwrj.text libno-plt-1b.dd}} \
76 "No PLT (dynamic 1a)" \
77 "$NOPIE_LDFLAGS tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
78 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
79 "-Wa,-mx86-used-note=yes" \
81 {{readelf -Wr no-plt-1a.rd} {objdump -dwrj.text no-plt-1a.dd}} \
85 "No PLT (dynamic 1b)" \
86 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
87 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
88 "-Wa,-mx86-used-note=yes" \
90 {{readelf -Wr no-plt-1b.rd} {objdump -dwrj.text no-plt-1b.dd}} \
94 "No PLT (dynamic 1c)" \
95 "$NOPIE_LDFLAGS tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
96 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
97 "-Wa,-mx86-used-note=yes" \
99 {{readelf -Wr no-plt-1c.rd} {objdump -dwrj.text no-plt-1c.dd}} \
103 "No PLT (static 1d)" \
104 "-static tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
105 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
106 "-Wa,-mx86-used-note=yes" \
108 {{readelf -Wr no-plt-1d.rd} {objdump -dwrj.text no-plt-1d.dd}} \
113 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
114 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
115 "-Wa,-mx86-used-note=yes" \
117 {{readelf -Wr no-plt-1e.rd} {nm -gD no-plt-1e.nd} {objdump -dwrj.text no-plt-1e.dd}} \
122 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
123 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
124 "-Wa,-mx86-used-note=yes" \
126 {{readelf -Wr no-plt-1f.rd} {objdump -dwrj.text no-plt-1f.dd}} \
131 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
132 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
133 "-Wa,-mx86-used-note=yes" \
135 {{readelf -Wr no-plt-1g.rd} {objdump -dwrj.text no-plt-1g.dd}} \
140 run_ld_link_exec_tests [list \
142 "No PLT (dynamic 1a)" \
143 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
144 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
145 "-Wa,-mx86-used-note=yes" \
151 "No PLT (dynamic 1b)" \
152 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
153 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
154 "-Wa,-mx86-used-note=yes" \
160 "No PLT (dynamic 1c)" \
161 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
162 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
163 "-Wa,-mx86-used-note=yes" \
169 "No PLT (static 1d)" \
170 "-static tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
171 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
172 "-Wa,-mx86-used-note=yes" \
179 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
180 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
181 "-Wa,-mx86-used-note=yes" \
188 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
189 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
190 "-Wa,-mx86-used-note=yes" \
197 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
198 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
199 "-Wa,-mx86-used-note=yes" \
206 # Run-time tests which require working IFUNC support.
207 if { [check_ifunc_available] } {
208 run_cc_link_tests [list \
210 "Build pr20253-2a.o pr20253-2b.o pr20253-2c.o pr20253-2d.o" \
212 "-fPIE -O2 -g -Wa,-mx86-used-note=yes" \
213 { pr20253-2a.c pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
216 "Build libpr20253-2a.so" \
217 "-shared tmpdir/pr20253-2b.o \
218 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
219 "-Wa,-mx86-used-note=yes" \
226 run_ld_link_exec_tests [list \
229 "tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \
230 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
231 "-Wa,-mx86-used-note=yes" \
238 "--static tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \
239 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
240 "-Wa,-mx86-used-note=yes" \
247 "-pie tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \
248 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
249 "-Wa,-mx86-used-note=yes" \
256 "tmpdir/pr20253-2a.o tmpdir/libpr20253-2a.so" \
257 "-Wa,-mx86-used-note=yes" \
264 "-pie tmpdir/pr20253-2a.o tmpdir/libpr20253-2a.so" \
265 "-Wa,-mx86-used-note=yes" \
272 "$NOPIE_LDFLAGS tmpdir/pr20253-2a.o" \
273 "-Wa,-mx86-used-note=yes" \
274 { pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
281 "--static tmpdir/pr20253-2a.o" \
282 "-Wa,-mx86-used-note=yes" \
283 { pr20253-2b.S pr20253-2c.S pr20253-2d.S } \