]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-loongarch-elf/pic.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-loongarch-elf / pic.exp
1 # Expect script for LoongArch ELF linker tests
2 # Copyright (C) 2022-2023 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 if ![istarget loongarch*-*-*] {
23 return
24 }
25
26 global verbose
27 set old_verbose verbose
28 # set verbose 3
29
30 # Check to see if the C compiler works
31 if { ![check_compiler_available] } {
32 return
33 }
34
35
36 set testname "nopic link test pre build"
37 set pre_builds [list \
38 [list \
39 "$testname" \
40 "-shared $NOSANITIZE_CFLAGS" \
41 "-fPIC $NOSANITIZE_CFLAGS" \
42 {libnopic-global.s} \
43 {} \
44 "libnopic-global.so" \
45 ] \
46 ]
47
48 # 0:name
49 # 1:ld or ar options
50 # 2:compile options
51 # 3:filenames of source files
52 # 4:action and options.
53 # 5:name of output file
54 # 6:language (optional)
55 run_cc_link_tests $pre_builds
56
57
58
59 set testname "nopic link test"
60
61 set link_tests [list \
62 [list \
63 "$testname readelf -s/-x nopic-local" \
64 "-T pic.ld" "" \
65 "" \
66 { nopic-local.s } \
67 [list \
68 [list readelf -s nopic-local.sd] \
69 [list readelf "-x .data" nopic-local.xd] \
70 ] \
71 "nopic-local" \
72 ] \
73 [list \
74 "$testname readelf -s/-x nopic-weak-local" \
75 "-T pic.ld" "" \
76 "" \
77 {nopic-weak-local.s} \
78 [list \
79 [list readelf -s nopic-weak-local.sd] \
80 [list readelf "-x .data" nopic-weak-local.xd] \
81 ] \
82 "nopic-weak-local" \
83 ] \
84 [list \
85 "$testname readelf -s/-x nopic-global" \
86 "-T pic.ld" "" \
87 "" \
88 {nopic-global.s libnopic-global.s} \
89 [list \
90 [list readelf -s nopic-global.sd] \
91 [list readelf "-x .data" nopic-global.xd] \
92 ] \
93 "nopic-global" \
94 ] \
95 [list \
96 "$testname readelf -s/-r nopic-global-so" \
97 "-L./tmpdir -lnopic-global -L/usr/lib -lc" "" \
98 "" \
99 {nopic-global.s} \
100 [list \
101 [list readelf -s nopic-global-so.sd] \
102 [list readelf -r nopic-global-so.rd] \
103 ] \
104 "nopic-global-so" \
105 ] \
106 [list \
107 "$testname readelf -s/-x nopic-weak-global" \
108 "-T pic.ld" "" \
109 "" \
110 {nopic-weak-global.s libnopic-global.s} \
111 [list \
112 [list readelf -s nopic-weak-global.sd] \
113 [list readelf "-x .data" nopic-weak-global.xd] \
114 ] \
115 "nopic-weak-global" \
116 ] \
117 [list \
118 "$testname readelf -s/-x nopic-weak-global-so" \
119 "-L./tmpdir -lnopic-global -L/usr/lib -lc" "" \
120 "" \
121 {nopic-weak-global.s} \
122 [list \
123 [list readelf -s nopic-weak-global-so.sd] \
124 [list readelf -r nopic-weak-global-so.rd] \
125 ] \
126 "nopic-weak-global-so" \
127 ] \
128 ]
129
130 # 0:name
131 # 1:ld/ar leading options, placed before object files
132 # 2:ld/ar trailing options, placed after object files
133 # 3:assembler options
134 # 4:filenames of assembler files
135 # 5:list of actions, options and expected outputs.
136 # 6:name of output file
137 # 7:compiler flags (optional)
138 run_ld_link_tests $link_tests
139
140 set testname "nopic link exec test"
141
142 set link_exec_tests [list \
143 [list \
144 "$testname" \
145 "" "" \
146 { nopic-local.s } \
147 "nopic-local" \
148 "nopic-local.out" \
149 ] \
150 [list \
151 "$testname" \
152 "" "" \
153 { nopic-weak-local.s } \
154 "nopic-weak-local" \
155 "nopic-weak-local.out" \
156 ] \
157 [list \
158 "$testname" \
159 "" "" \
160 { nopic-global.s libnopic-global.s } \
161 "nopic-global" \
162 "nopic-global.out" \
163 ] \
164 [list \
165 "$testname" \
166 "-L./tmpdir -lnopic-global -lc -Wl,-rpath=./tmpdir -no-pie" "" \
167 { nopic-global.s } \
168 "nopic-global-so" \
169 "nopic-global.out" \
170 ] \
171 [list \
172 "$testname" \
173 "" "" \
174 { nopic-weak-global.s libnopic-global.s } \
175 "nopic-weak-global" \
176 "nopic-weak-global.out" \
177 ] \
178 [list \
179 "$testname" \
180 "-L./tmpdir -lnopic-global -lc -Wl,-rpath=./tmpdir -no-pie" "" \
181 { nopic-weak-global.s } \
182 "nopic-weak-global-so" \
183 "nopic-weak-global.out" \
184 ] \
185 ]
186
187 # ldtests contains test-items with 3 items followed by 1 lists, 2 items
188 # and 3 optional items:
189 # 0:name
190 # 1:ld leading options, placed before object files
191 # 2:assembler options
192 # 3:filenames of source files
193 # 4:name of output file
194 # 5:expected output
195 # 6:compiler flags (optional)
196 # 7:language (optional)
197 # 8:linker warning (optional)
198 # 9:ld trailing options, placed after object files (optional)
199 run_ld_link_exec_tests $link_exec_tests
200
201
202 #set verbose old_verbose