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