]>
Commit | Line | Data |
---|---|---|
1 | # Copyright (C) 2012-2017 Free Software Foundation, Inc. | |
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 | ||
17 | # | |
18 | # elf tests | |
19 | # | |
20 | ||
21 | proc run_elf_list_test { name suffix opts readelf_opts readelf_pipe } { | |
22 | global READELF | |
23 | global srcdir subdir | |
24 | set testname "elf $name list" | |
25 | set file $srcdir/$subdir/$name | |
26 | gas_run ${name}.s "$opts -o dump.o" ">&dump.out" | |
27 | if { ![string match "" $opts] | |
28 | && [regexp_diff "dump.out" "${file}.l"] } then { | |
29 | fail $testname | |
30 | verbose "output is [file_contents "dump.out"]" 2 | |
31 | return | |
32 | } | |
33 | send_log "$READELF $readelf_opts dump.o $readelf_pipe > dump.out\n" | |
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 | |
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 | |
47 | if { [regexp_diff "dump.out" "${file}.e${suffix}"] } then { | |
48 | fail $testname | |
49 | verbose "output is [file_contents "dump.out"]" 2 | |
50 | return | |
51 | } | |
52 | pass $testname | |
53 | } | |
54 | ||
55 | # We're testing bits in obj-elf -- don't run on anything else. | |
56 | if { [is_elf_format] } then { | |
57 | set target_machine "" | |
58 | if {[istarget "mips*-*-*"]} then { | |
59 | set target_machine -mips | |
60 | } | |
61 | if {[istarget m32r*-*-*]} then { | |
62 | set target_machine -m32r | |
63 | } | |
64 | if {[istarget "msp430-*-*"]} then { | |
65 | set target_machine -msp430 | |
66 | } | |
67 | if {[istarget "score-*-*"]} then { | |
68 | set target_machine -score | |
69 | } | |
70 | if {[istarget "tic6x-*-*"]} then { | |
71 | set target_machine -tic6x | |
72 | } | |
73 | if {[istarget "xtensa*-*-*"]} then { | |
74 | set target_machine -xtensa | |
75 | } | |
76 | if {[istarget "rx-*-*"]} then { | |
77 | set target_machine -rx | |
78 | } | |
79 | if {[istarget "v850*-*-*"]} then { | |
80 | set target_machine -v850 | |
81 | } | |
82 | if {[istarget "rl78-*-*"]} then { | |
83 | set target_machine -rl78 | |
84 | } | |
85 | if {[istarget "arm*-*-*"]} { | |
86 | set target_machine -arm | |
87 | } | |
88 | ||
89 | # The MN10300 and Xtensa ports disable the assembler's call frame | |
90 | # optimization because it interfers with link-time relaxation of | |
91 | # function prologues. | |
92 | if {![istarget "mn10300-*-*"] | |
93 | && ![istarget "xtensa*-*-*"] | |
94 | && ![istarget "msp430*-*-*"] | |
95 | && ![istarget "nds32*-*-*"] | |
96 | && ![istarget "am3*-*-*"]} then { | |
97 | run_dump_test "ehopt0" | |
98 | } | |
99 | case $target_triplet in { | |
100 | { m68k-*-* m68[03]??-*-* } { | |
101 | run_dump_test "file" { { as "--defsym m68k=1" } } | |
102 | } | |
103 | { mmix-*-* } { | |
104 | run_dump_test "file" { { as "--defsym mmix=1" } } | |
105 | } | |
106 | { xtensa*-*-* } { | |
107 | run_dump_test "file" { { as "--rename-section file.s=file.c" } } | |
108 | } | |
109 | default { | |
110 | run_dump_test "file" | |
111 | } | |
112 | } | |
113 | run_dump_test "file-2" | |
114 | setup_xfail "nds32*-*-*" | |
115 | run_dump_test "group0a" | |
116 | run_dump_test "group0b" | |
117 | run_dump_test "group0c" | |
118 | run_dump_test "group1a" | |
119 | run_dump_test "group1b" | |
120 | run_dump_test "group2" | |
121 | case $target_triplet in { | |
122 | { hppa64*-*-hpux* } { } | |
123 | { riscv*-*-* } { } | |
124 | default { | |
125 | run_dump_test "groupautoa" | |
126 | } | |
127 | } | |
128 | case $target_triplet in { | |
129 | { hppa64*-*-hpux* } { } | |
130 | { riscv*-*-* } { } | |
131 | { xtensa*-*-* } { } | |
132 | default { | |
133 | run_dump_test "groupautob" | |
134 | } | |
135 | } | |
136 | case $target_triplet in { | |
137 | { alpha*-*-* } { } | |
138 | { *c54x*-*-* } { } | |
139 | { cr16*-*-* } { } | |
140 | { crx*-*-* } { } | |
141 | { h8300-*-* } { } | |
142 | { hppa*-*-* } { } | |
143 | { iq2000*-*-* } { } | |
144 | { mips*-*-* } { } | |
145 | { mn10200-*-* } { } | |
146 | { mn10300-*-* } { } | |
147 | { msp43*-*-* } { } | |
148 | { rl78-*-* } { } | |
149 | { riscv*-*-* } { } | |
150 | { rx-*-* } { } | |
151 | default { | |
152 | # The next test can fail if the target does not convert fixups | |
153 | # against ordinary symbols into relocations against section symbols. | |
154 | # This is usually revealed by the error message: | |
155 | # symbol `sym' required but not present | |
156 | setup_xfail "m681*-*-*" "m68hc*-*-*" "xgate-*-*" "vax-*-*" | |
157 | run_dump_test redef | |
158 | run_dump_test equ-reloc | |
159 | } | |
160 | } | |
161 | run_dump_test "pseudo" | |
162 | run_dump_test "section0" | |
163 | run_dump_test "section1" | |
164 | if {! [istarget "h8300-*-*"]} then { | |
165 | # The h8300 port issues a warning message for | |
166 | # new sections created without atrributes. | |
167 | run_elf_list_test "section2" "$target_machine" "-al" "-s" "" | |
168 | } | |
169 | run_dump_test "section3" | |
170 | run_dump_test "section4" | |
171 | if {! [istarget "h8300-*-*"] && ! [istarget "rx-*-*"]} then { | |
172 | # The h8300 port issues a warning message for | |
173 | # new sections created without atrributes. | |
174 | # The RX port does not complain about changing the attributes of the | |
175 | # .data and .bss sections since it does not use those names. | |
176 | run_elf_list_test "section5" "" "-al" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\"" | |
177 | } | |
178 | run_dump_test "struct" | |
179 | if { ![istarget "alpha*-*-*"] } then { | |
180 | # The alpha port uses .set for state, e.g. nomacro. | |
181 | run_dump_test "symtab" | |
182 | } | |
183 | run_dump_test "symver" | |
184 | ||
185 | # No indirect functions on non-GNU targets. | |
186 | # The Visium and MSP set the ELF header's OSABI field to ELFOSABI_STANDALONE. | |
187 | # The non-eabi ARM ports sets it to ELFOSABI_ARM. | |
188 | # So for these targets we cannot include an IFUNC symbol type | |
189 | # in the symbol type test. | |
190 | # We also need to exclude targets that do not support unique objects. | |
191 | if { [istarget "*-*-hpux*"] | |
192 | || [istarget "arm*-*-*"] | |
193 | || [istarget "msp*-*-*"] | |
194 | || [istarget "visium-*-*"] | |
195 | || ![supports_gnu_unique] | |
196 | } then { | |
197 | # hppa64 has a non-standard common directive | |
198 | if { ![istarget "hppa64*-*-hpux*"] } then { | |
199 | run_elf_list_test "type-noifunc" "" "" "-s" "| grep \"1 *\\\[FONTC\\\]\"" | |
200 | } | |
201 | } else { | |
202 | run_dump_test ifunc-1 | |
203 | run_elf_list_test "type" "" "" "-s" "| grep \"1 *\\\[FIONTCU\\\]\"" | |
204 | } | |
205 | ||
206 | run_dump_test "section6" | |
207 | run_dump_test "section7" | |
208 | run_dump_test "section8" | |
209 | run_dump_test "section9" | |
210 | run_dump_test "section10" | |
211 | run_dump_test "section11" | |
212 | run_dump_test "section12a" | |
213 | run_dump_test "section12b" | |
214 | run_dump_test "section13" | |
215 | run_dump_test "dwarf2-1" | |
216 | run_dump_test "dwarf2-2" | |
217 | run_dump_test "dwarf2-3" | |
218 | run_dump_test "dwarf2-4" | |
219 | run_dump_test "bss" | |
220 | run_dump_test "bad-bss" | |
221 | run_dump_test "bad-section-flag" | |
222 | run_dump_test "bad-size" | |
223 | run_dump_test "bad-group" | |
224 | ||
225 | run_dump_test "syms" | |
226 | ||
227 | # hpux has a non-standard common directive. | |
228 | if { ![istarget "*-*-hpux*"] } then { | |
229 | run_dump_test "common1" | |
230 | run_dump_test "common2" | |
231 | run_dump_test "common3a" | |
232 | run_dump_test "common3b" | |
233 | run_dump_test "common4a" | |
234 | run_dump_test "common4b" | |
235 | } | |
236 | ||
237 | run_dump_test "strtab" | |
238 | ||
239 | run_dump_test "bignums" | |
240 | ||
241 | load_lib gas-dg.exp | |
242 | dg-init | |
243 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" "" | |
244 | dg-finish | |
245 | } |