1 # Copyright (C) 2012-2019 Free Software Foundation, Inc.
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.
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.
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.
21 proc run_elf_list_test { name suffix opts readelf_opts readelf_pipe } {
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 {
30 verbose "output is [file_contents "dump.out"]" 2
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"
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"
46 verbose_eval {[file_contents "dump.out"]} 3
47 if { [regexp_diff "dump.out" "${file}.e${suffix}"] } then {
49 verbose "output is [file_contents "dump.out"]" 2
55 # We're testing bits in obj-elf -- don't run on anything else.
56 if { [is_elf_format] } then {
58 if {[istarget "mips*-*-*"]} then {
59 set target_machine -mips
61 if {[istarget m32r*-*-*]} then {
62 set target_machine -m32r
64 if {[istarget "msp430-*-*"]} then {
65 set target_machine -msp430
67 if {[istarget "score-*-*"]} then {
68 set target_machine -score
70 if {[istarget "tic6x-*-*"]} then {
71 set target_machine -tic6x
73 if {[istarget "xtensa*-*-*"]} then {
74 set target_machine -xtensa
76 if {[istarget "rx-*-*"]} then {
77 set target_machine -rx
79 if {[istarget "riscv*-*-*"]} then {
80 set target_machine -riscv
82 if {[istarget "v850*-*-*"]} then {
83 set target_machine -v850
85 if {[istarget "rl78-*-*"]} then {
86 set target_machine -rl78
88 if {[istarget "arm*-*-*"]} {
89 set target_machine -arm
91 if {[istarget "arc*-*-*"]} {
92 set target_machine -arc
95 # The MN10300 and Xtensa ports disable the assembler's call frame
96 # optimization because it interfers with link-time relaxation of
98 if {![istarget "mn10300-*-*"]
99 && ![istarget "am3*-*-*"]
100 && ![istarget "xtensa*-*-*"]
101 && ![istarget "msp430*-*-*"]
102 && ![istarget "nds32*-*-*"]
103 && ![istarget "am3*-*-*"]} then {
104 run_dump_test "ehopt0"
106 case $target_triplet in {
107 { m68k-*-* m68[03]??-*-* } {
108 run_dump_test "file" { { as "--defsym m68k=1" } }
111 run_dump_test "file" { { as "--defsym mmix=1" } }
114 run_dump_test "file" { { as "--rename-section file.s=file.c" } }
120 run_dump_test "file-2"
121 setup_xfail "nds32*-*-*"
122 run_dump_test "group0a"
123 run_dump_test "group0b"
124 run_dump_test "group0c"
125 run_dump_test "group1a"
126 run_dump_test "group1b"
127 run_dump_test "group2"
128 run_dump_test "group3"
129 case $target_triplet in {
130 { hppa64*-*-hpux* } { }
133 run_dump_test "groupautoa"
136 case $target_triplet in {
137 { hppa64*-*-hpux* } { }
141 run_dump_test "groupautob"
144 case $target_triplet in {
161 # The next test can fail if the target does not convert fixups
162 # against ordinary symbols into relocations against section symbols.
163 # This is usually revealed by the error message:
164 # symbol `sym' required but not present
165 setup_xfail "m681*-*-*" "m68hc*-*-*" "xgate-*-*" "vax-*-*"
167 run_dump_test equ-reloc
170 run_dump_test "pseudo"
171 run_dump_test "section0"
172 run_dump_test "section1"
173 if {! [istarget "h8300-*-*"]} then {
174 # The h8300 port issues a warning message for
175 # new sections created without atrributes.
176 case $target_triplet in {
177 { i*86-*-* x86_64-*-* } {
178 run_elf_list_test "section2" "$target_machine" "-al -mx86-used-note=no" "-s" ""
181 run_elf_list_test "section2" "$target_machine" "-al -march-attr" "-s" ""
184 run_elf_list_test "section2" "$target_machine" "-al" "-s" ""
188 run_dump_test "section3"
189 run_dump_test "section4"
190 if {! [istarget "h8300-*-*"] && ! [istarget "rx-*-*"]} then {
191 # The h8300 port issues a warning message for
192 # new sections created without atrributes.
193 # The RX port does not complain about changing the attributes of the
194 # .data and .bss sections since it does not use those names.
195 run_elf_list_test "section5" "" "-al" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
197 run_dump_test "struct"
198 if { ![istarget "alpha*-*-*"] } then {
199 # The alpha port uses .set for state, e.g. nomacro.
200 run_dump_test "symtab"
202 run_dump_test "symver"
203 run_dump_test "pr21661"
205 # No indirect functions on non-GNU targets.
206 # The Visium and MSP set the ELF header's OSABI field to ELFOSABI_STANDALONE.
207 # The non-eabi ARM ports sets it to ELFOSABI_ARM.
208 # So for these targets we cannot include an IFUNC symbol type
209 # in the symbol type test.
210 # We also need to exclude targets that do not support unique objects.
211 if { [istarget "*-*-hpux*"]
212 || [istarget "arm*-*-*"]
213 || [istarget "msp*-*-*"]
214 || [istarget "visium-*-*"]
215 || ![supports_gnu_unique]
217 # hppa64 has a non-standard common directive
218 if { ![istarget "hppa64*-*-hpux*"] } then {
219 run_elf_list_test "type-noifunc" "" "" "-s" "| grep \"1 *\\\[FONTC\\\]\""
222 run_dump_test ifunc-1
223 run_elf_list_test "type" "" "" "-s" "| grep \"1 *\\\[FIONTCU\\\]\""
226 run_dump_test "section6"
227 run_dump_test "section7"
228 run_dump_test "section8"
229 run_dump_test "section9"
230 run_dump_test "section10"
231 run_dump_test "section11"
232 run_dump_test "section12a"
233 run_dump_test "section12b"
234 run_dump_test "section13"
235 run_dump_test "section14"
236 run_dump_test "dwarf2-1"
237 run_dump_test "dwarf2-2"
238 run_dump_test "dwarf2-3"
239 run_dump_test "dwarf2-4"
240 run_dump_test "dwarf2-5"
241 run_dump_test "dwarf2-6"
242 run_dump_test "dwarf2-7"
243 run_dump_test "dwarf2-8"
244 run_dump_test "dwarf2-9"
245 run_dump_test "dwarf2-10"
246 run_dump_test "dwarf2-11"
247 run_dump_test "dwarf2-12"
248 run_dump_test "dwarf2-13"
249 run_dump_test "dwarf2-14"
250 run_dump_test "dwarf2-15"
251 run_dump_test "dwarf2-16"
252 run_dump_test "dwarf2-17"
253 run_dump_test "dwarf2-18"
255 run_dump_test "bad-bss"
256 run_dump_test "bad-section-flag"
257 run_dump_test "bad-size"
258 run_dump_test "bad-group"
262 run_dump_test "missing-build-notes"
264 run_dump_test "common1"
265 run_dump_test "common2"
267 # hpux has a non-standard common directive.
268 if { ![istarget "*-*-hpux*"] } then {
269 run_dump_test "common3a"
270 run_dump_test "common3b"
271 run_dump_test "common4a"
272 run_dump_test "common4b"
273 run_dump_test "common5a"
274 run_dump_test "common5b"
275 run_dump_test "common5c"
276 run_dump_test "common5d"
279 run_dump_test "strtab"
281 run_dump_test "bignums"
285 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""