2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
22 proc run_elf_list_test { name suffix opts readelf_opts readelf_pipe } {
25 set testname "elf $name list"
26 set file $srcdir/$subdir/$name
27 gas_run ${name}.s "$opts -o dump.o" ">&dump.out"
28 if { ![string match "" $opts]
29 && [regexp_diff "dump.out" "${file}.l"] } then {
31 verbose "output is [file_contents "dump.out"]" 2
34 send_log "$READELF $readelf_opts dump.o $readelf_pipe > dump.out\n"
35 set status [gas_host_run "$READELF $readelf_opts dump.o" ">readelf.out"]
36 if { [lindex $status 0] != 0 || ![string match "" [lindex $status 1]] } then {
37 send_log "[lindex $status 1]\n"
41 catch "exec cat readelf.out $readelf_pipe > dump.out\n" comp_output
42 if ![string match "" $comp_output] then {
43 send_log "$comp_output\n"
47 verbose_eval {[file_contents "dump.out"]} 3
48 if { [regexp_diff "dump.out" "${file}.e${suffix}"] } then {
50 verbose "output is [file_contents "dump.out"]" 2
56 # We're testing bits in obj-elf -- don't run on anything else.
57 if { [is_elf_format] } then {
59 if {[istarget "mips*-*-*"]} then {
60 set target_machine -mips
62 if {[istarget m32r*-*-*]} then {
63 set target_machine -m32r
65 if {[istarget "score-*-*"]} then {
66 set target_machine -score
68 if {[istarget "tic6x-*-*"]} then {
69 set target_machine -tic6x
71 if {[istarget "xtensa*-*-*"]} then {
72 set target_machine -xtensa
74 if {[istarget "rx-*-*"]} then {
75 set target_machine -rx
77 if {[istarget "arm*-*-*"]} {
79 if { ([istarget "*-*-*eabi"]
80 || [istarget "*-*-linux-*"]
81 || [istarget "*-*-nacl*"]
82 || [istarget "*-*-symbianelf"])} then {
83 set target_machine -armeabi
85 set target_machine -armelf
89 # The MN10300 and Xtensa ports disable the assembler's call frame
90 # optimization because it interfers with link-time relaxation of
92 if {![istarget "mn10300-*-*"]
93 && ![istarget "xtensa*-*-*"]
94 && ![istarget "am3*-*-*"]} then {
95 run_dump_test "ehopt0"
97 case $target_triplet in {
98 { m68k-*-* m68[03]??-*-* } {
99 run_dump_test "file" { { as "--defsym m68k=1" } }
102 run_dump_test "file" { { as "--defsym mmix=1" } }
105 run_dump_test "file" { { as "--rename-section file.s=file.c" } }
111 run_dump_test "group0a"
112 run_dump_test "group0b"
113 run_dump_test "group0c"
114 run_dump_test "group1a"
115 run_dump_test "group1b"
116 case $target_triplet in {
117 { hppa64*-*-hpux* } { }
119 run_dump_test "groupautoa"
122 case $target_triplet in {
123 { hppa64*-*-hpux* } { }
126 run_dump_test "groupautob"
129 case $target_triplet in {
142 # The next test can fail if the target does not convert fixups
143 # against ordinary symbols into relocations against section symbols.
144 # This is usually revealed by the error message:
145 # symbol `sym' required but not present
146 setup_xfail "m681*-*-*" "m68hc*-*-*"
148 run_dump_test equ-reloc
151 run_dump_test "pseudo"
152 run_dump_test "section0"
153 run_dump_test "section1"
154 if {! [istarget "h8300-*-*"]} then {
155 # The h8300 port issues a warning message for
156 # new sections created without atrributes.
157 run_elf_list_test "section2" "$target_machine" "-al" "-s" ""
159 run_dump_test "section3"
160 run_dump_test "section4"
161 if {! [istarget "h8300-*-*"] && ! [istarget "rx-*-*"]} then {
162 # The h8300 port issues a warning message for
163 # new sections created without atrributes.
164 # The RX port does not complain about changing the attributes of the
165 # .data and .bss sections since it does not use those names.
166 run_elf_list_test "section5" "" "-al" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
168 run_dump_test "struct"
169 if { ![istarget "alpha*-*-*"] } then {
170 # The alpha port uses .set for state, e.g. nomacro.
171 run_dump_test "symtab"
173 run_dump_test "symver"
175 # No indirect functions on non-GNU targets.
176 # The MSP port sets the ELF header's OSABI field to ELFOSABI_STANDALONE.
177 # The non-eabi ARM ports sets it to ELFOSABI_ARM.
178 # So for these targets we cannot include an IFUNC symbol type
179 # in the symbol type test.
180 if { [istarget "*-*-hpux*"]
181 || [istarget "msp*-*-*"]
182 || [istarget "arm*-*-*"]} then {
183 # hppa64 has a non-standard common directive
184 if { ![istarget "hppa64*-*-hpux*"] } then {
185 run_elf_list_test "type-noifunc" "" "" "-s" "| grep \"1 *\\\[FONTC\\\]\""
188 run_dump_test ifunc-1
189 run_elf_list_test "type" "" "" "-s" "| grep \"1 *\\\[FIONTCU\\\]\""
192 run_dump_test "section6"
193 run_dump_test "section7"
194 run_dump_test "section8"
195 run_dump_test "section9"
196 run_dump_test "dwarf2-1"
197 run_dump_test "dwarf2-2"
198 run_dump_test "dwarf2-3"
199 run_dump_test "dwarf2-4"
200 run_dump_test "bad-section-flag"
201 run_dump_test "bad-size"
202 run_dump_test "bad-group"
206 run_dump_test "common1"
207 run_dump_test "common2"
211 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""