1 # Copyright (C) 2012-2021 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 {
57 if { [is_elf_unused_section_symbols ] } {
58 set target_machine -unused
63 if {[istarget "arc*-*-*"]} {
64 set target_machine -arc
66 if {[istarget "arm*-*-*"]} {
67 set target_machine -arm
69 if {[istarget "avr*-*-*"]} {
70 set dump_opts {{as -mno-link-relax}}
72 if {[istarget "csky*-*-*"]} {
73 set target_machine -csky
75 if {[istarget "m32r*-*-*"]} then {
76 set target_machine -m32r
78 if {[istarget "mips*-*-*"]} then {
79 set target_machine -mips
81 if {[istarget "msp430-*-*"]} then {
82 set target_machine -msp430
84 if {[istarget "pru-*-*"]} {
85 set dump_opts {{as -mno-link-relax}}
87 if {[istarget "riscv*-*-*"]} then {
88 set target_machine -riscv
89 set dump_opts {{as -mno-relax}}
91 if {[istarget "rl78-*-*"]} then {
92 set target_machine -rl78
94 if {[istarget "rx-*-*"]} then {
95 set target_machine -rx
97 if {[istarget "score-*-*"]} then {
98 set target_machine -score
100 if {[istarget "tic6x-*-*"]} then {
101 set target_machine -tic6x
103 if {[istarget "v850*-*-*"]} then {
104 set target_machine -v850
106 if {[istarget "xtensa*-*-*"]} then {
107 set target_machine -xtensa
108 set dump_opts {{as --no-link-relax}}
111 # The MN10300 and Xtensa ports disable the assembler's call frame
112 # optimization because it interfers with link-time relaxation of
113 # function prologues.
114 if {![istarget "mn10300-*-*"]
115 && ![istarget "am3*-*-*"]
116 && ![istarget "xtensa*-*-*"]
117 && ![istarget "msp430*-*-*"]
118 && ![istarget "nds32*-*-*"]
119 && ![istarget "am3*-*-*"]} then {
120 run_dump_test "ehopt0"
122 switch -glob $target_triplet {
125 run_dump_test "file" { { as "--defsym m68k=1" } }
128 run_dump_test "file" { { as "--defsym mmix=1" } }
131 run_dump_test "file" { { as "--rename-section file.s=file.c" } }
137 run_dump_test "file-2"
138 setup_xfail "nds32*-*-*"
139 run_dump_test "group0a"
140 run_dump_test "group0b"
141 run_dump_test "group0c"
142 run_dump_test "group1a"
143 run_dump_test "group1b"
144 run_dump_test "group2"
145 run_dump_test "group3"
147 run_dump_test "attach-1"
148 run_dump_test "attach-err"
150 switch -glob $target_triplet {
154 run_dump_test "groupautoa"
157 switch -glob $target_triplet {
162 run_dump_test "groupautob"
165 switch -glob $target_triplet {
183 # The next test can fail if the target does not convert fixups
184 # against ordinary symbols into relocations against section symbols.
185 # This is usually revealed by the error message:
186 # symbol `sym' required but not present
187 setup_xfail "m681*-*-*" "m68hc*-*-*" "xgate-*-*" "vax-*-*"
189 run_dump_test equ-reloc
192 run_dump_test "pseudo"
193 run_dump_test "section0"
194 run_dump_test "section1"
195 # The h8300 port issues a warning message for
196 # new sections created without atrributes.
197 if {! [istarget "h8300-*-*"]} then {
198 set as_flags "-al --generate-missing-build-notes=no"
199 switch -glob $target_triplet {
202 set as_flags "$as_flags -mx86-used-note=no"
205 set as_flags "$as_flags -march-attr"
208 run_elf_list_test "section2" "$target_machine" "$as_flags" "-s" ""
210 run_dump_test "section3"
211 run_dump_test "section4"
212 if {! [istarget "h8300-*-*"] && ! [istarget "rx-*-*"]} then {
213 # The h8300 port issues a warning message for
214 # new sections created without atrributes.
215 # The RX port does not complain about changing the attributes of the
216 # .data and .bss sections since it does not use those names.
217 run_elf_list_test "section5" "" "-al -Z" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
219 run_dump_test "struct"
220 if { ![istarget "alpha*-*-*"] } then {
221 # The alpha port uses .set for state, e.g. nomacro.
222 run_dump_test "symtab"
224 run_dump_test "symver"
225 run_dump_test "pr21661"
226 run_dump_test "pr14891"
228 # No indirect functions on non-GNU targets.
229 # The Visium and MSP set the ELF header's OSABI field to ELFOSABI_STANDALONE.
230 # The non-eabi ARM ports sets it to ELFOSABI_ARM.
231 # So for these targets we cannot include an IFUNC symbol type
232 # in the symbol type test.
233 # We also need to exclude targets that do not support unique objects.
234 if { [istarget "*-*-hpux*"]
235 || [istarget "arm*-*-*"]
236 || [istarget "mips*-*-*"]
237 || [istarget "msp*-*-*"]
238 || [istarget "visium-*-*"]
239 || ![supports_gnu_unique]
241 # hppa64 has a non-standard common directive
242 if { ![istarget "hppa64*-*-hpux*"] } then {
243 run_elf_list_test "type-noifunc" "" "" "-s" "| grep \"1 *\\\[FONTC\\\]\""
246 run_dump_test ifunc-1
247 run_elf_list_test "type" "" "" "-s" "| grep \"1 *\\\[FIONTCU\\\]\""
248 run_elf_list_test "type-2" "" "--warn" "-s" "| grep \"0 *\\\[FIONT\\\]\""
251 run_dump_test "section6"
252 run_dump_test "section7"
253 run_dump_test "section8"
254 run_dump_test "section9"
255 run_dump_test "section10"
256 run_dump_test "section11"
257 run_dump_test "section12a"
258 run_dump_test "section12b"
259 run_dump_test "section13"
260 run_dump_test "section14"
261 run_dump_test "section15"
262 run_dump_test "section16a"
263 run_dump_test "section16b"
264 run_dump_test "section17"
265 run_dump_test "section18"
266 run_dump_test "section19"
267 run_dump_test "section20"
268 run_dump_test "section21"
269 run_dump_test "section22"
270 run_dump_test "section23a"
271 run_dump_test "section23b"
272 run_dump_test "section24a"
273 run_dump_test "section24b"
274 run_dump_test "section25"
275 run_dump_test "section26"
276 run_dump_test "section27"
277 run_dump_test "section28"
278 run_dump_test "section29"
279 run_dump_test "sh-link-zero"
280 run_dump_test "dwarf2-1" $dump_opts
281 run_dump_test "dwarf2-2" $dump_opts
282 run_dump_test "dwarf2-3" $dump_opts
283 run_dump_test "dwarf2-4" $dump_opts
284 run_dump_test "dwarf2-5" $dump_opts
285 run_dump_test "dwarf2-6" $dump_opts
286 run_dump_test "dwarf2-7" $dump_opts
287 run_dump_test "dwarf2-8" $dump_opts
288 run_dump_test "dwarf2-9" $dump_opts
289 run_dump_test "dwarf2-10" $dump_opts
290 run_dump_test "dwarf2-11" $dump_opts
291 run_dump_test "dwarf2-12" $dump_opts
292 run_dump_test "dwarf2-13" $dump_opts
293 run_dump_test "dwarf2-14" $dump_opts
294 run_dump_test "dwarf2-15" $dump_opts
295 run_dump_test "dwarf2-16" $dump_opts
296 run_dump_test "dwarf2-17" $dump_opts
297 run_dump_test "dwarf2-18" $dump_opts
298 run_dump_test "dwarf2-19" $dump_opts
299 run_dump_test "dwarf2-20" $dump_opts
300 run_dump_test "dwarf2-21" $dump_opts
301 run_dump_test "dwarf-5-file0" $dump_opts
302 run_dump_test "dwarf-5-file0-2" $dump_opts
303 run_dump_test "dwarf-5-file0-3" $dump_opts
304 run_dump_test "dwarf-5-dir0" $dump_opts
305 run_dump_test "dwarf-5-loc0" $dump_opts
306 run_dump_test "dwarf-4-cu" $dump_opts
307 run_dump_test "dwarf-5-cu" $dump_opts
308 run_dump_test "dwarf-5-nop-for-line-table" $dump_opts
309 run_dump_test "pr25917"
311 run_dump_test "bad-bss"
312 run_dump_test "bad-section-flag"
313 run_dump_test "bad-size"
314 run_dump_test "bad-group"
315 run_dump_test "pr27355"
318 run_dump_test "startof"
320 run_dump_test "missing-build-notes"
322 run_dump_test "common1"
323 run_dump_test "common2"
325 # hpux has a non-standard common directive.
326 if { ![istarget "*-*-hpux*"] } then {
327 run_dump_test "common3a"
328 run_dump_test "common3b"
329 run_dump_test "common4a"
330 run_dump_test "common4b"
331 run_dump_test "common5a"
332 run_dump_test "common5b"
333 run_dump_test "common5c"
334 run_dump_test "common5d"
337 run_dump_test "strtab"
339 run_dump_test "bignums"
340 run_dump_test "section-symbol-redef"
341 run_dump_test "pr27228"