]> 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
250d07de 1# Copyright (C) 2012-2021 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 {
fa6b2d59 57 set target_machine ""
762172a4
AM
58 set dump_opts ""
59 if {[istarget "arc*-*-*"]} {
60 set target_machine -arc
61 }
62 if {[istarget "arm*-*-*"]} {
63 set target_machine -arm
64 }
65 if {[istarget "avr*-*-*"]} {
66 set dump_opts {{as -mno-link-relax}}
0861f561
CQ
67 }
68 if {[istarget "csky*-*-*"]} {
69 set target_machine -csky
fa6b2d59 70 }
762172a4 71 if {[istarget "m32r*-*-*"]} then {
6a7715f4
NC
72 set target_machine -m32r
73 }
762172a4
AM
74 if {[istarget "mips*-*-*"]} then {
75 set target_machine -mips
76 }
13761a11
NC
77 if {[istarget "msp430-*-*"]} then {
78 set target_machine -msp430
79 }
762172a4
AM
80 if {[istarget "pru-*-*"]} {
81 set dump_opts {{as -mno-link-relax}}
1c0d3aa6 82 }
762172a4
AM
83 if {[istarget "riscv*-*-*"]} then {
84 set target_machine -riscv
85 set dump_opts {{as -mno-relax}}
59e6276b 86 }
762172a4
AM
87 if {[istarget "rl78-*-*"]} then {
88 set target_machine -rl78
2caa7ca0 89 }
c7927a3c
NC
90 if {[istarget "rx-*-*"]} then {
91 set target_machine -rx
92 }
762172a4
AM
93 if {[istarget "score-*-*"]} then {
94 set target_machine -score
95 }
96 if {[istarget "tic6x-*-*"]} then {
97 set target_machine -tic6x
2dc8dd17 98 }
685080f2
NC
99 if {[istarget "v850*-*-*"]} then {
100 set target_machine -v850
101 }
762172a4
AM
102 if {[istarget "xtensa*-*-*"]} then {
103 set target_machine -xtensa
104 set dump_opts {{as --no-link-relax}}
53a346d8 105 }
8c750480 106
ee6365aa
BW
107 # The MN10300 and Xtensa ports disable the assembler's call frame
108 # optimization because it interfers with link-time relaxation of
109 # function prologues.
110 if {![istarget "mn10300-*-*"]
75800d2c 111 && ![istarget "am3*-*-*"]
ee6365aa 112 && ![istarget "xtensa*-*-*"]
13761a11 113 && ![istarget "msp430*-*-*"]
35c08157 114 && ![istarget "nds32*-*-*"]
01642c12 115 && ![istarget "am3*-*-*"]} then {
8c750480
NC
116 run_dump_test "ehopt0"
117 }
e3696f67
AM
118 switch -glob $target_triplet {
119 m68k-*-* -
120 m68[03]??-*-* {
efa19bfd
JB
121 run_dump_test "file" { { as "--defsym m68k=1" } }
122 }
e3696f67 123 mmix-*-* {
efa19bfd
JB
124 run_dump_test "file" { { as "--defsym mmix=1" } }
125 }
e3696f67 126 xtensa*-*-* {
efa19bfd
JB
127 run_dump_test "file" { { as "--rename-section file.s=file.c" } }
128 }
129 default {
130 run_dump_test "file"
131 }
132 }
fbdf9406 133 run_dump_test "file-2"
35c08157 134 setup_xfail "nds32*-*-*"
01642c12
RM
135 run_dump_test "group0a"
136 run_dump_test "group0b"
709001e9 137 run_dump_test "group0c"
01642c12
RM
138 run_dump_test "group1a"
139 run_dump_test "group1b"
5f3fd8b4 140 run_dump_test "group2"
7d36e279 141 run_dump_test "group3"
642f545a
NC
142
143 run_dump_test "attach-1"
144 run_dump_test "attach-err"
b71702f1 145
e3696f67
AM
146 switch -glob $target_triplet {
147 hppa64*-*-hpux* { }
148 riscv*-*-* { }
516e75be
AM
149 default {
150 run_dump_test "groupautoa"
151 }
152 }
e3696f67
AM
153 switch -glob $target_triplet {
154 hppa64*-*-hpux* { }
155 riscv*-*-* { }
156 xtensa*-*-* { }
5ff3e4be
AM
157 default {
158 run_dump_test "groupautob"
159 }
160 }
e3696f67
AM
161 switch -glob $target_triplet {
162 alpha*-*-* { }
163 am3*-*-* { }
164 *c54x*-*-* { }
165 cr16*-*-* { }
166 crx*-*-* { }
167 h8300-*-* { }
168 hppa*-*-* { }
169 iq2000*-*-* { }
170 mips*-*-* { }
171 mn10200-*-* { }
172 mn10300-*-* { }
173 msp43*-*-* { }
174 rl78-*-* { }
175 riscv*-*-* { }
176 rx-*-* { }
5ca0ee01 177 default {
7b5030c0
NC
178 # The next test can fail if the target does not convert fixups
179 # against ordinary symbols into relocations against section symbols.
180 # This is usually revealed by the error message:
181 # symbol `sym' required but not present
3ee6e4fb 182 setup_xfail "m681*-*-*" "m68hc*-*-*" "xgate-*-*" "vax-*-*"
5ca0ee01 183 run_dump_test redef
bdf128d6 184 run_dump_test equ-reloc
5ca0ee01
JB
185 }
186 }
6e8bd58f 187 run_dump_test "pseudo"
01642c12
RM
188 run_dump_test "section0"
189 run_dump_test "section1"
077a039f
NC
190 # The h8300 port issues a warning message for
191 # new sections created without atrributes.
52b010e4 192 if {! [istarget "h8300-*-*"]} then {
077a039f 193 set as_flags "-al --generate-missing-build-notes=no"
e3696f67
AM
194 switch -glob $target_triplet {
195 i*86-*-* -
196 x86_64-*-* {
077a039f 197 set as_flags "$as_flags -mx86-used-note=no"
2dc8dd17 198 }
e3696f67 199 riscv*-*-* {
077a039f 200 set as_flags "$as_flags -march-attr"
2dc8dd17 201 }
5e8a54c6 202 }
077a039f 203 run_elf_list_test "section2" "$target_machine" "$as_flags" "-s" ""
52b010e4 204 }
01642c12 205 run_dump_test "section3"
22fe14ad 206 run_dump_test "section4"
a22429b9 207 if {! [istarget "h8300-*-*"] && ! [istarget "rx-*-*"]} then {
52b010e4
NC
208 # The h8300 port issues a warning message for
209 # new sections created without atrributes.
a22429b9
NC
210 # The RX port does not complain about changing the attributes of the
211 # .data and .bss sections since it does not use those names.
33176d91 212 run_elf_list_test "section5" "" "-al -Z" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
52b010e4 213 }
01642c12 214 run_dump_test "struct"
79c07750
RH
215 if { ![istarget "alpha*-*-*"] } then {
216 # The alpha port uses .set for state, e.g. nomacro.
217 run_dump_test "symtab"
218 }
d8045f23 219 run_dump_test "symver"
a3aea05a 220 run_dump_test "pr21661"
f1f28025 221 run_dump_test "pr14891"
d8045f23 222
516e75be 223 # No indirect functions on non-GNU targets.
b6605ddd 224 # The Visium and MSP set the ELF header's OSABI field to ELFOSABI_STANDALONE.
cec7aa6a
AM
225 # The non-eabi ARM ports sets it to ELFOSABI_ARM.
226 # So for these targets we cannot include an IFUNC symbol type
227 # in the symbol type test.
eb9bb5b4 228 # We also need to exclude targets that do not support unique objects.
3ee6e4fb 229 if { [istarget "*-*-hpux*"]
8e4979ac
NC
230 || [istarget "arm*-*-*"]
231 || [istarget "mips*-*-*"]
232 || [istarget "msp*-*-*"]
3ee6e4fb 233 || [istarget "visium-*-*"]
eb9bb5b4 234 || ![supports_gnu_unique]
3ee6e4fb 235 } then {
516e75be
AM
236 # hppa64 has a non-standard common directive
237 if { ![istarget "hppa64*-*-hpux*"] } then {
017761ea 238 run_elf_list_test "type-noifunc" "" "" "-s" "| grep \"1 *\\\[FONTC\\\]\""
516e75be 239 }
cec7aa6a 240 } else {
516e75be
AM
241 run_dump_test ifunc-1
242 run_elf_list_test "type" "" "" "-s" "| grep \"1 *\\\[FIONTCU\\\]\""
f2d4ba38 243 run_elf_list_test "type-2" "" "--warn" "-s" "| grep \"0 *\\\[FIONT\\\]\""
d8045f23
NC
244 }
245
01642c12
RM
246 run_dump_test "section6"
247 run_dump_test "section7"
248 run_dump_test "section8"
68efed41 249 run_dump_test "section9"
9fb71ee4 250 run_dump_test "section10"
2edb36e7 251 run_dump_test "section11"
a91e1603
L
252 run_dump_test "section12a"
253 run_dump_test "section12b"
254 run_dump_test "section13"
385e5b90 255 run_dump_test "section14"
a8c4d40b
L
256 run_dump_test "section15"
257 run_dump_test "section16a"
258 run_dump_test "section16b"
259 run_dump_test "section17"
b7d07216
L
260 run_dump_test "section18"
261 run_dump_test "section19"
262 run_dump_test "section20"
263 run_dump_test "section21"
99fabbc9
JL
264 run_dump_test "section22"
265 run_dump_test "section23a"
266 run_dump_test "section23b"
267 run_dump_test "section24a"
268 run_dump_test "section24b"
2c6f3e56
JL
269 run_dump_test "section25"
270 run_dump_test "section26"
037311d1 271 run_dump_test "section27"
b71702f1 272 run_dump_test "sh-link-zero"
762172a4
AM
273 run_dump_test "dwarf2-1" $dump_opts
274 run_dump_test "dwarf2-2" $dump_opts
275 run_dump_test "dwarf2-3" $dump_opts
276 run_dump_test "dwarf2-4" $dump_opts
277 run_dump_test "dwarf2-5" $dump_opts
278 run_dump_test "dwarf2-6" $dump_opts
279 run_dump_test "dwarf2-7" $dump_opts
280 run_dump_test "dwarf2-8" $dump_opts
281 run_dump_test "dwarf2-9" $dump_opts
282 run_dump_test "dwarf2-10" $dump_opts
283 run_dump_test "dwarf2-11" $dump_opts
284 run_dump_test "dwarf2-12" $dump_opts
285 run_dump_test "dwarf2-13" $dump_opts
286 run_dump_test "dwarf2-14" $dump_opts
287 run_dump_test "dwarf2-15" $dump_opts
288 run_dump_test "dwarf2-16" $dump_opts
289 run_dump_test "dwarf2-17" $dump_opts
290 run_dump_test "dwarf2-18" $dump_opts
291 run_dump_test "dwarf2-19" $dump_opts
bcb78b47 292 run_dump_test "dwarf2-20" $dump_opts
84d9ab33 293 run_dump_test "dwarf-5-file0" $dump_opts
a3b3e858
MW
294 run_dump_test "dwarf-4-cu" $dump_opts
295 run_dump_test "dwarf-5-cu" $dump_opts
b1766e7c 296 run_dump_test "dwarf-5-nop-for-line-table" $dump_opts
4706679d 297 run_dump_test "pr25917"
ec9ab52c
JB
298 run_dump_test "bss"
299 run_dump_test "bad-bss"
8f3bae45 300 run_dump_test "bad-section-flag"
093a6ec6 301 run_dump_test "bad-size"
cfba7fd5 302 run_dump_test "bad-group"
9aec2026 303
7bfd842d 304 run_dump_test "syms"
b84f59ef
NC
305
306 run_dump_test "missing-build-notes"
7bfd842d 307
0b1352e0
AM
308 run_dump_test "common1"
309 run_dump_test "common2"
310
742e5034
L
311 # hpux has a non-standard common directive.
312 if { ![istarget "*-*-hpux*"] } then {
b8871f35
L
313 run_dump_test "common3a"
314 run_dump_test "common3b"
315 run_dump_test "common4a"
316 run_dump_test "common4b"
76db0a2e
L
317 run_dump_test "common5a"
318 run_dump_test "common5b"
319 run_dump_test "common5c"
320 run_dump_test "common5d"
742e5034 321 }
f3aa8054 322
ef10c3ac
L
323 run_dump_test "strtab"
324
5f2b6bc9 325 run_dump_test "bignums"
d4d05d13 326 run_dump_test "section-symbol-redef"
9aec2026 327
5f2b6bc9
NC
328 load_lib gas-dg.exp
329 dg-init
330 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
331 dg-finish
98944905 332}