1 # Expect script for x86-64 TLS 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.
29 # Only on Linux for now.
30 if ![istarget "x86_64-*-linux*"] {
34 # Check to see if the C compiler works
35 if { ![check_compiler_available] } {
39 run_cc_link_tests [list \
41 "Build tls-def1.o tls-main1.o" \
43 "-fPIE -Wa,-mx86-used-note=yes" \
44 {tls-def1.c tls-main1.c} \
47 "Build tls-gd1.o tls-ld1.o" \
49 "-fPIC -Wa,-mrelax-relocations=yes,-mx86-used-note=yes" \
50 {tls-gd1.S tls-ld1.S} \
53 "Build libtls-1a.so" \
54 "-shared tmpdir/tls-def1.o" \
55 "-Wa,-mx86-used-note=yes" \
61 "Build libtls-1b.so" \
62 "-shared tmpdir/tls-gd1.o tmpdir/tls-ld1.o" \
63 "-Wa,-mx86-used-note=yes" \
69 "Build libtls-1bn.so" \
70 "-Wl,-z,now -shared tmpdir/tls-gd1.o tmpdir/tls-ld1.o" \
71 "-Wa,-mx86-used-note=yes" \
78 run_ld_link_exec_tests [list \
80 "TLS GD/LD -> LE transition without PLT (dynamic)" \
81 "tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \
83 "-Wa,-mx86-used-note=yes" \
89 "TLS GD/LD -> LE transition without PLT (dynamic, -z now)" \
90 "-Wl,-z,now tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \
92 "-Wa,-mx86-used-note=yes" \
98 "TLS GD/LD -> LE transition without PLT (PIE)" \
99 "-pie tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \
101 "-Wa,-mx86-used-note=yes" \
107 "TLS GD/LD -> LE transition without PLT (PIE, -z now)" \
108 "-pie -Wl,-z,now tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \
110 "-Wa,-mx86-used-note=yes" \
116 "TLS GD/LD -> LE transition without PLT (static)" \
117 "-static tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \
119 "-Wa,-mx86-used-note=yes" \
125 "TLS GD/LD -> IE transition without PLT" \
126 "-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
127 tmpdir/tls-gd1.o tmpdir/tls-ld1.o tmpdir/libtls-1a.so" \
128 "-Wa,-mx86-used-note=yes" \
134 "TLS GD/LD -> IE transition without PLT (-z now)" \
135 "-Wl,-z,now tmpdir/tls-main1.o tmpdir/tls-gd1.o tmpdir/tls-ld1.o \
136 tmpdir/libtls-1a.so -Wl,-R,tmpdir" \
137 "-Wa,-mx86-used-note=yes" \
143 "TLS without PLT (1)" \
144 "-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
145 tmpdir/libtls-1a.so tmpdir/libtls-1b.so" \
146 "-Wa,-mx86-used-note=yes" \
152 "TLS without PLT (2)" \
153 "-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
154 tmpdir/tls-def1.o tmpdir/libtls-1b.so" \
155 "-Wa,-mx86-used-note=yes" \
161 "TLS without PLT (3)" \
162 "-Wl,--no-as-needed -Wl,-z,now tmpdir/tls-main1.o \
163 tmpdir/libtls-1a.so tmpdir/libtls-1bn.so -Wl,-R,tmpdir" \
164 "-Wa,-mx86-used-note=yes" \
170 "TLS without PLT (4)" \
171 "-Wl,-z,now tmpdir/tls-main1.o tmpdir/tls-def1.o \
172 tmpdir/libtls-1bn.so -Wl,-R,tmpdir" \
173 "-Wa,-mx86-used-note=yes" \
180 # -mtls-dialect=gnu2 isn't supported on x32.
181 if [istarget "x86_64-*-linux*-gnux32"] {
185 run_cc_link_tests [list \
187 "Build libtlsdesc1.so" \
189 "-fPIC $GNU2_CFLAGS -Wa,-mx86-used-note=yes" \
195 "Build libtlsdesc1n.so" \
196 "-Wl,-z,now -shared" \
197 "-fPIC $GNU2_CFLAGS -Wa,-mx86-used-note=yes" \
204 # Run-time tests which require working GNU2 TLS support.
205 if { ![check_gnu2_tls_available] } {
209 if { [at_least_gcc_version 5 0] } {
210 run_ld_link_exec_tests [list \
213 "-Wl,--no-as-needed tmpdir/libtlsdesc1.so" \
214 "-Wa,-mx86-used-note=yes" \
221 "Run tlsdesc1 with PIE" \
222 "-pie -Wl,--no-as-needed tmpdir/libtlsdesc1.so" \
223 "-Wa,-mx86-used-note=yes" \
227 "-fPIE $GNU2_CFLAGS" \
232 run_ld_link_exec_tests [list \
234 "Run tlsdesc1 (-z now)" \
235 "-Wl,-z,now -Wl,--no-as-needed tmpdir/libtlsdesc1n.so" \
236 "-Wa,-mx86-used-note=yes" \
243 "Run tlsdesc1 with PIE (-z now)" \
244 "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/libtlsdesc1n.so" \
245 "-Wa,-mx86-used-note=yes" \
249 "-fPIE $GNU2_CFLAGS" \