1# Expect script for i386 TLS tests. 2# Copyright (C) 2016-2021 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# 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. 25if ![isnative] { 26 return 27} 28 29# Only on Linux for now. 30if ![istarget "i?86-*-linux*"] { 31 return 32} 33 34# Check to see if the C compiler works 35if { ![check_compiler_available] } { 36 return 37} 38 39run_cc_link_tests [list \ 40 [list \ 41 "Build tls-def1.o tls-main1.o" \ 42 "" \ 43 "-fPIE -Wa,-mx86-used-note=yes" \ 44 {tls-def1.c tls-main1.c} \ 45 ] \ 46 [list \ 47 "Build tls-gd1.o tls-ld1.o" \ 48 "" \ 49 "-fPIC -Wa,-mrelax-relocations=yes,-mx86-used-note=yes" \ 50 {tls-gd1.S tls-ld1.S} \ 51 ] \ 52 [list \ 53 "Build libtls-1a.so" \ 54 "-shared tmpdir/tls-def1.o" \ 55 "-Wa,-mx86-used-note=yes" \ 56 {dummy.s} \ 57 {} \ 58 "libtls-1a.so" \ 59 ] \ 60 [list \ 61 "Build libtls-1b.so" \ 62 "-shared tmpdir/tls-gd1.o tmpdir/tls-ld1.o" \ 63 "-Wa,-mx86-used-note=yes" \ 64 {dummy.s} \ 65 {} \ 66 "libtls-1b.so" \ 67 ] \ 68 [list \ 69 "Build libtls-1bn.so" \ 70 "-Wl,-z,now -shared tmpdir/tls-gd1.o tmpdir/tls-ld1.o" \ 71 "-Wa,-mx86-used-note=yes" \ 72 {dummy.s} \ 73 {} \ 74 "libtls-1bn.so" \ 75 ] \ 76] 77 78run_ld_link_exec_tests [list \ 79 [list \ 80 "TLS GD/LD -> LE transition without PLT (dynamic)" \ 81 "tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \ 82 tmpdir/tls-ld1.o" \ 83 "-Wa,-mx86-used-note=yes" \ 84 { dummy.s } \ 85 "tls-1a" \ 86 "pass.out" \ 87 ] \ 88 [list \ 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 \ 91 tmpdir/tls-ld1.o" \ 92 "-Wa,-mx86-used-note=yes" \ 93 { dummy.s } \ 94 "tls-1an" \ 95 "pass.out" \ 96 ] \ 97 [list \ 98 "TLS GD/LD -> LE transition without PLT (PIE)" \ 99 "-pie tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \ 100 tmpdir/tls-ld1.o" \ 101 "-Wa,-mx86-used-note=yes" \ 102 { dummy.s } \ 103 "tls-1b" \ 104 "pass.out" \ 105 ] \ 106 [list \ 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 \ 109 tmpdir/tls-ld1.o" \ 110 "-Wa,-mx86-used-note=yes" \ 111 { dummy.s } \ 112 "tls-1bn" \ 113 "pass.out" \ 114 ] \ 115 [list \ 116 "TLS GD/LD -> LE transition without PLT (static)" \ 117 "-static tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \ 118 tmpdir/tls-ld1.o" \ 119 "-Wa,-mx86-used-note=yes" \ 120 { dummy.s } \ 121 "tls-1c" \ 122 "pass.out" \ 123 ] \ 124 [list \ 125 "TLS GD/LD -> IE transition without PLT" \ 126 "tmpdir/tls-main1.o tmpdir/tls-gd1.o tmpdir/tls-ld1.o \ 127 tmpdir/libtls-1a.so -Wl,-R,tmpdir" \ 128 "-Wa,-mx86-used-note=yes" \ 129 { dummy.s } \ 130 "tls-1d" \ 131 "pass.out" \ 132 ] \ 133 [list \ 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" \ 138 { dummy.s } \ 139 "tls-1dn" \ 140 "pass.out" \ 141 ] \ 142 [list \ 143 "TLS without PLT (1)" \ 144 "-Wl,--no-as-needed tmpdir/tls-main1.o \ 145 tmpdir/libtls-1a.so tmpdir/libtls-1b.so -Wl,-R,tmpdir" \ 146 "-Wa,-mx86-used-note=yes" \ 147 { dummy.s } \ 148 "tls-1e" \ 149 "pass.out" \ 150 ] \ 151 [list \ 152 "TLS without PLT (2)" \ 153 "tmpdir/tls-main1.o tmpdir/tls-def1.o \ 154 tmpdir/libtls-1b.so -Wl,-R,tmpdir" \ 155 "-Wa,-mx86-used-note=yes" \ 156 { dummy.s } \ 157 "tls-1f" \ 158 "pass.out" \ 159 ] \ 160 [list \ 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" \ 165 { dummy.s } \ 166 "tls-1en" \ 167 "pass.out" \ 168 ] \ 169 [list \ 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" \ 174 { dummy.s } \ 175 "tls-1fn" \ 176 "pass.out" \ 177 ] \ 178] 179 180# Run-time tests which require working GNU2 TLS support. 181if { ![check_gnu2_tls_available] } { 182 return 183} 184 185run_cc_link_tests [list \ 186 [list \ 187 "Build libtlsdesc1.so" \ 188 "-shared" \ 189 "-fPIC $GNU2_CFLAGS -Wa,-mx86-used-note=yes" \ 190 { tlsdesc1b.c } \ 191 {} \ 192 "libtlsdesc1.so" \ 193 ] \ 194 [list \ 195 "Build libtlsdesc1n.so" \ 196 "-Wl,-z,now -shared" \ 197 "-fPIC $GNU2_CFLAGS -Wa,-mx86-used-note=yes" \ 198 { tlsdesc1b.c } \ 199 {} \ 200 "libtlsdesc1n.so" \ 201 ] \ 202] 203 204run_ld_link_exec_tests [list \ 205 [list \ 206 "Run tlsdesc1" \ 207 "-Wl,--no-as-needed tmpdir/libtlsdesc1.so" \ 208 "-Wa,-mx86-used-note=yes" \ 209 { tlsdesc1a.c } \ 210 "tlsdesc1a" \ 211 "pass.out" \ 212 "$GNU2_CFLAGS" \ 213 ] \ 214 [list \ 215 "Run tlsdesc1 (-z now)" \ 216 "-Wl,-z,now -Wl,--no-as-needed tmpdir/libtlsdesc1n.so" \ 217 "-Wa,-mx86-used-note=yes" \ 218 { tlsdesc1a.c } \ 219 "tlsdesc1b" \ 220 "pass.out" \ 221 "$GNU2_CFLAGS" \ 222 ] \ 223 [list \ 224 "Run tlsdesc1 with PIE" \ 225 "-pie -Wl,--no-as-needed tmpdir/libtlsdesc1.so" \ 226 "-Wa,-mx86-used-note=yes" \ 227 { tlsdesc1a.c } \ 228 "tlsdesc1c" \ 229 "pass.out" \ 230 "-fPIE $GNU2_CFLAGS" \ 231 ] \ 232 [list \ 233 "Run tlsdesc1 with PIE (-z now)" \ 234 "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/libtlsdesc1n.so" \ 235 "-Wa,-mx86-used-note=yes" \ 236 { tlsdesc1a.c } \ 237 "tlsdesc1d" \ 238 "pass.out" \ 239 "-fPIE $GNU2_CFLAGS" \ 240 ] \ 241] 242