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