]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gas/testsuite/gas/elf/elf.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / gas / testsuite / gas / elf / elf.exp
CommitLineData
a2c58332 1# Copyright (C) 2012-2022 Free Software Foundation, Inc.
5bf135a7
NC
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
16
98944905
RH
17#
18# elf tests
19#
20
dfeb0666 21proc run_elf_list_test { name suffix opts readelf_opts readelf_pipe } {
5b5032eb
L
22 global READELF
23 global srcdir subdir
24 set testname "elf $name list"
02e07694 25 set file $srcdir/$subdir/$name
5b5032eb 26 gas_run ${name}.s "$opts -o dump.o" ">&dump.out"
5c1aa77e 27 if { ![string match "" $opts]
eb22018c 28 && [regexp_diff "dump.out" "${file}.l"] } then {
5b5032eb
L
29 fail $testname
30 verbose "output is [file_contents "dump.out"]" 2
31 return
32 }
7a6d0b32 33 send_log "$READELF $readelf_opts dump.o $readelf_pipe > dump.out\n"
7f6a71ff
JM
34 set status [gas_host_run "$READELF $readelf_opts dump.o" ">readelf.out"]
35 if { [lindex $status 0] != 0 || ![string match "" [lindex $status 1]] } then {
36 send_log "[lindex $status 1]\n"
37 fail $testname
38 return
39 }
40 catch "exec cat readelf.out $readelf_pipe > dump.out\n" comp_output
5b5032eb
L
41 if ![string match "" $comp_output] then {
42 send_log "$comp_output\n"
43 fail $testname
44 return
45 }
46 verbose_eval {[file_contents "dump.out"]} 3
eb22018c 47 if { [regexp_diff "dump.out" "${file}.e${suffix}"] } then {
5b5032eb
L
48 fail $testname
49 verbose "output is [file_contents "dump.out"]" 2
50 return
51 }
52 pass $testname
53}
54
98944905 55# We're testing bits in obj-elf -- don't run on anything else.
017761ea 56if { [is_elf_format] } then {
d1bcae83
L
57 if { [is_elf_unused_section_symbols ] } {
58 set target_machine -unused
59 } else {
60 set target_machine ""
61 }
762172a4
AM
62 set dump_opts ""
63 if {[istarget "arc*-*-*"]} {
64 set target_machine -arc
65 }
66 if {[istarget "arm*-*-*"]} {
67 set target_machine -arm
68 }
69 if {[istarget "avr*-*-*"]} {
70 set dump_opts {{as -mno-link-relax}}
0861f561
CQ
71 }
72 if {[istarget "csky*-*-*"]} {
73 set target_machine -csky
fa6b2d59 74 }
762172a4 75 if {[istarget "m32r*-*-*"]} then {
6a7715f4
NC
76 set target_machine -m32r
77 }
762172a4
AM
78 if {[istarget "mips*-*-*"]} then {
79 set target_machine -mips
80 }
13761a11
NC
81 if {[istarget "msp430-*-*"]} then {
82 set target_machine -msp430
83 }
762172a4
AM
84 if {[istarget "pru-*-*"]} {
85 set dump_opts {{as -mno-link-relax}}
1c0d3aa6 86 }
762172a4
AM
87 if {[istarget "riscv*-*-*"]} then {
88 set target_machine -riscv
89 set dump_opts {{as -mno-relax}}
59e6276b 90 }
762172a4
AM
91 if {[istarget "rl78-*-*"]} then {
92 set target_machine -rl78
2caa7ca0 93 }
c7927a3c
NC
94 if {[istarget "rx-*-*"]} then {
95 set target_machine -rx
96 }
762172a4
AM
97 if {[istarget "score-*-*"]} then {
98 set target_machine -score
99 }
100 if {[istarget "tic6x-*-*"]} then {
101 set target_machine -tic6x
2dc8dd17 102 }
685080f2
NC
103 if {[istarget "v850*-*-*"]} then {
104 set target_machine -v850
105 }
762172a4
AM
106 if {[istarget "xtensa*-*-*"]} then {
107 set target_machine -xtensa
108 set dump_opts {{as --no-link-relax}}
53a346d8 109 }
8c750480 110
ee6365aa
BW
111 # The MN10300 and Xtensa ports disable the assembler's call frame
112 # optimization because it interfers with link-time relaxation of
113 # function prologues.
114 if {![istarget "mn10300-*-*"]
75800d2c 115 && ![istarget "am3*-*-*"]
ee6365aa 116 && ![istarget "xtensa*-*-*"]
13761a11 117 && ![istarget "msp430*-*-*"]
35c08157 118 && ![istarget "nds32*-*-*"]
01642c12 119 && ![istarget "am3*-*-*"]} then {
8c750480
NC
120 run_dump_test "ehopt0"
121 }
e3696f67
AM
122 switch -glob $target_triplet {
123 m68k-*-* -
124 m68[03]??-*-* {
efa19bfd
JB
125 run_dump_test "file" { { as "--defsym m68k=1" } }
126 }
e3696f67 127 mmix-*-* {
efa19bfd
JB
128 run_dump_test "file" { { as "--defsym mmix=1" } }
129 }
e3696f67 130 xtensa*-*-* {
efa19bfd
JB
131 run_dump_test "file" { { as "--rename-section file.s=file.c" } }
132 }
133 default {
134 run_dump_test "file"
135 }
136 }
fbdf9406 137 run_dump_test "file-2"
35c08157 138 setup_xfail "nds32*-*-*"
01642c12
RM
139 run_dump_test "group0a"
140 run_dump_test "group0b"
709001e9 141 run_dump_test "group0c"
01642c12
RM
142 run_dump_test "group1a"
143 run_dump_test "group1b"
5f3fd8b4 144 run_dump_test "group2"
7d36e279 145 run_dump_test "group3"
642f545a
NC
146
147 run_dump_test "attach-1"
148 run_dump_test "attach-err"
b71702f1 149
e3696f67
AM
150 switch -glob $target_triplet {
151 hppa64*-*-hpux* { }
152 riscv*-*-* { }
516e75be
AM
153 default {
154 run_dump_test "groupautoa"
155 }
156 }
e3696f67
AM
157 switch -glob $target_triplet {
158 hppa64*-*-hpux* { }
159 riscv*-*-* { }
160 xtensa*-*-* { }
5ff3e4be
AM
161 default {
162 run_dump_test "groupautob"
163 }
164 }
e3696f67
AM
165 switch -glob $target_triplet {
166 alpha*-*-* { }
167 am3*-*-* { }
168 *c54x*-*-* { }
169 cr16*-*-* { }
170 crx*-*-* { }
171 h8300-*-* { }
172 hppa*-*-* { }
173 iq2000*-*-* { }
174 mips*-*-* { }
175 mn10200-*-* { }
176 mn10300-*-* { }
177 msp43*-*-* { }
178 rl78-*-* { }
179 riscv*-*-* { }
180 rx-*-* { }
4462d7c4 181 loongarch*-*-* { }
5ca0ee01 182 default {
7b5030c0
NC
183 # The next test can fail if the target does not convert fixups
184 # against ordinary symbols into relocations against section symbols.
185 # This is usually revealed by the error message:
186 # symbol `sym' required but not present
f3be70df 187 setup_xfail "m681*-*-*" "m68hc*-*-*" "xgate-*-*" "vax-*-*" "avr-*-*"
5ca0ee01 188 run_dump_test redef
bdf128d6 189 run_dump_test equ-reloc
5ca0ee01
JB
190 }
191 }
6e8bd58f 192 run_dump_test "pseudo"
01642c12
RM
193 run_dump_test "section0"
194 run_dump_test "section1"
077a039f
NC
195 # The h8300 port issues a warning message for
196 # new sections created without atrributes.
52b010e4 197 if {! [istarget "h8300-*-*"]} then {
077a039f 198 set as_flags "-al --generate-missing-build-notes=no"
e3696f67
AM
199 switch -glob $target_triplet {
200 i*86-*-* -
201 x86_64-*-* {
077a039f 202 set as_flags "$as_flags -mx86-used-note=no"
2dc8dd17 203 }
e3696f67 204 riscv*-*-* {
077a039f 205 set as_flags "$as_flags -march-attr"
2dc8dd17 206 }
5e8a54c6 207 }
077a039f 208 run_elf_list_test "section2" "$target_machine" "$as_flags" "-s" ""
52b010e4 209 }
01642c12 210 run_dump_test "section3"
22fe14ad 211 run_dump_test "section4"
a22429b9 212 if {! [istarget "h8300-*-*"] && ! [istarget "rx-*-*"]} then {
52b010e4
NC
213 # The h8300 port issues a warning message for
214 # new sections created without atrributes.
a22429b9
NC
215 # The RX port does not complain about changing the attributes of the
216 # .data and .bss sections since it does not use those names.
33176d91 217 run_elf_list_test "section5" "" "-al -Z" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
52b010e4 218 }
01642c12 219 run_dump_test "struct"
79c07750
RH
220 if { ![istarget "alpha*-*-*"] } then {
221 # The alpha port uses .set for state, e.g. nomacro.
222 run_dump_test "symtab"
223 }
d8045f23 224 run_dump_test "symver"
a3aea05a 225 run_dump_test "pr21661"
f1f28025 226 run_dump_test "pr14891"
d8045f23 227
516e75be 228 # No indirect functions on non-GNU targets.
b6605ddd 229 # The Visium and MSP set the ELF header's OSABI field to ELFOSABI_STANDALONE.
cec7aa6a
AM
230 # The non-eabi ARM ports sets it to ELFOSABI_ARM.
231 # So for these targets we cannot include an IFUNC symbol type
232 # in the symbol type test.
eb9bb5b4 233 # We also need to exclude targets that do not support unique objects.
3ee6e4fb 234 if { [istarget "*-*-hpux*"]
8e4979ac
NC
235 || [istarget "arm*-*-*"]
236 || [istarget "mips*-*-*"]
237 || [istarget "msp*-*-*"]
3ee6e4fb 238 || [istarget "visium-*-*"]
eb9bb5b4 239 || ![supports_gnu_unique]
3ee6e4fb 240 } then {
516e75be
AM
241 # hppa64 has a non-standard common directive
242 if { ![istarget "hppa64*-*-hpux*"] } then {
017761ea 243 run_elf_list_test "type-noifunc" "" "" "-s" "| grep \"1 *\\\[FONTC\\\]\""
516e75be 244 }
cec7aa6a 245 } else {
516e75be
AM
246 run_dump_test ifunc-1
247 run_elf_list_test "type" "" "" "-s" "| grep \"1 *\\\[FIONTCU\\\]\""
f2d4ba38 248 run_elf_list_test "type-2" "" "--warn" "-s" "| grep \"0 *\\\[FIONT\\\]\""
d8045f23
NC
249 }
250
01642c12
RM
251 run_dump_test "section6"
252 run_dump_test "section7"
253 run_dump_test "section8"
68efed41 254 run_dump_test "section9"
9fb71ee4 255 run_dump_test "section10"
2edb36e7 256 run_dump_test "section11"
a91e1603
L
257 run_dump_test "section12a"
258 run_dump_test "section12b"
259 run_dump_test "section13"
385e5b90 260 run_dump_test "section14"
a8c4d40b
L
261 run_dump_test "section15"
262 run_dump_test "section16a"
263 run_dump_test "section16b"
264 run_dump_test "section17"
b7d07216
L
265 run_dump_test "section18"
266 run_dump_test "section19"
267 run_dump_test "section20"
268 run_dump_test "section21"
99fabbc9
JL
269 run_dump_test "section22"
270 run_dump_test "section23a"
271 run_dump_test "section23b"
272 run_dump_test "section24a"
273 run_dump_test "section24b"
2c6f3e56
JL
274 run_dump_test "section25"
275 run_dump_test "section26"
037311d1 276 run_dump_test "section27"
ca1289b9
L
277 run_dump_test "section28"
278 run_dump_test "section29"
b71702f1 279 run_dump_test "sh-link-zero"
762172a4
AM
280 run_dump_test "dwarf2-1" $dump_opts
281 run_dump_test "dwarf2-2" $dump_opts
282 run_dump_test "dwarf2-3" $dump_opts
283 run_dump_test "dwarf2-4" $dump_opts
284 run_dump_test "dwarf2-5" $dump_opts
285 run_dump_test "dwarf2-6" $dump_opts
286 run_dump_test "dwarf2-7" $dump_opts
287 run_dump_test "dwarf2-8" $dump_opts
288 run_dump_test "dwarf2-9" $dump_opts
289 run_dump_test "dwarf2-10" $dump_opts
290 run_dump_test "dwarf2-11" $dump_opts
291 run_dump_test "dwarf2-12" $dump_opts
292 run_dump_test "dwarf2-13" $dump_opts
293 run_dump_test "dwarf2-14" $dump_opts
294 run_dump_test "dwarf2-15" $dump_opts
295 run_dump_test "dwarf2-16" $dump_opts
296 run_dump_test "dwarf2-17" $dump_opts
297 run_dump_test "dwarf2-18" $dump_opts
298 run_dump_test "dwarf2-19" $dump_opts
bcb78b47 299 run_dump_test "dwarf2-20" $dump_opts
cf11ebea 300 run_dump_test "dwarf2-21" $dump_opts
84d9ab33 301 run_dump_test "dwarf-5-file0" $dump_opts
58f3b6a3 302 run_dump_test "dwarf-5-file0-2" $dump_opts
f9402cca 303 run_dump_test "dwarf-5-file0-3" $dump_opts
3417bfca 304 run_dump_test "dwarf-5-dir0" $dump_opts
689580da 305 run_dump_test "dwarf-5-loc0" $dump_opts
a3b3e858
MW
306 run_dump_test "dwarf-4-cu" $dump_opts
307 run_dump_test "dwarf-5-cu" $dump_opts
b1766e7c 308 run_dump_test "dwarf-5-nop-for-line-table" $dump_opts
4706679d 309 run_dump_test "pr25917"
ec9ab52c
JB
310 run_dump_test "bss"
311 run_dump_test "bad-bss"
8f3bae45 312 run_dump_test "bad-section-flag"
093a6ec6 313 run_dump_test "bad-size"
cfba7fd5 314 run_dump_test "bad-group"
52563b0f 315 run_dump_test "pr27355"
9aec2026 316
7bfd842d 317 run_dump_test "syms"
162c6aef 318 run_dump_test "startof"
b84f59ef
NC
319
320 run_dump_test "missing-build-notes"
7bfd842d 321
0b1352e0
AM
322 run_dump_test "common1"
323 run_dump_test "common2"
324
742e5034
L
325 # hpux has a non-standard common directive.
326 if { ![istarget "*-*-hpux*"] } then {
b8871f35
L
327 run_dump_test "common3a"
328 run_dump_test "common3b"
329 run_dump_test "common4a"
330 run_dump_test "common4b"
76db0a2e
L
331 run_dump_test "common5a"
332 run_dump_test "common5b"
333 run_dump_test "common5c"
334 run_dump_test "common5d"
742e5034 335 }
f3aa8054 336
ef10c3ac
L
337 run_dump_test "strtab"
338
5f2b6bc9 339 run_dump_test "bignums"
d4d05d13 340 run_dump_test "section-symbol-redef"
eea133e6 341 run_dump_test "pr27228"
98944905 342}