1# Expect script for x86-64 TLS tests.
2#   Copyright (C) 2016 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 "x86_64-*-linux*"] {
31    return
32}
33
34# Check to see if the C compiler works
35if { [which $CC] == 0 } {
36    return
37}
38
39run_cc_link_tests [list \
40    [list \
41	"Build tls-def1.o tls-main1.o" \
42	"" \
43	"-fPIE" \
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" \
50	{tls-gd1.S tls-ld1.S} \
51    ] \
52    [list \
53	"Build libtls-1a.so" \
54	"-shared tmpdir/tls-def1.o" \
55	"" \
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	"" \
64	{dummy.s} \
65	{} \
66	"libtls-1b.so" \
67    ] \
68]
69
70run_ld_link_exec_tests [] [list \
71    [list \
72	"TLS GD/LD -> LE transition without PLT (dynamic)" \
73	"tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \
74	 tmpdir/tls-ld1.o" \
75	"" \
76	{ dummy.s } \
77	"tls-1a" \
78	"pass.out" \
79    ] \
80    [list \
81	"TLS GD/LD -> LE transition without PLT (PIE)" \
82	"-pie tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \
83	 tmpdir/tls-ld1.o" \
84	"" \
85	{ dummy.s } \
86	"tls-1b" \
87	"pass.out" \
88    ] \
89    [list \
90	"TLS GD/LD -> LE transition without PLT (static)" \
91	"-static tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \
92	 tmpdir/tls-ld1.o" \
93	"" \
94	{ dummy.s } \
95	"tls-1c" \
96	"pass.out" \
97    ] \
98    [list \
99	"TLS GD/LD -> IE transition without PLT" \
100	"tmpdir/tls-main1.o tmpdir/tls-gd1.o tmpdir/tls-ld1.o \
101	 tmpdir/libtls-1a.so -R tmpdir" \
102	"" \
103	{ dummy.s } \
104	"tls-1d" \
105	"pass.out" \
106    ] \
107    [list \
108	"TLS without PLT (1)" \
109	"tmpdir/tls-main1.o \
110	 tmpdir/libtls-1a.so tmpdir/libtls-1b.so -R tmpdir" \
111	"" \
112	{ dummy.s } \
113	"tls-1e" \
114	"pass.out" \
115    ] \
116    [list \
117	"TLS without PLT (2)" \
118	"tmpdir/tls-main1.o tmpdir/tls-def1.o \
119	 tmpdir/libtls-1b.so -R tmpdir" \
120	"" \
121	{ dummy.s } \
122	"tls-1f" \
123	"pass.out" \
124    ] \
125]
126