]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gas/testsuite/gas/elf/elf.exp
Add a testcase for group error.
[thirdparty/binutils-gdb.git] / gas / testsuite / gas / elf / elf.exp
1 #
2 # elf tests
3 #
4
5 proc run_elf_list_test { name suffix opts readelf_opts readelf_pipe } {
6 global READELF
7 global srcdir subdir
8 set testname "elf $name list"
9 set file $srcdir/$subdir/$name
10 gas_run ${name}.s "$opts -o dump.o" ">&dump.out"
11 if { ![string match "" $opts]
12 && [regexp_diff "dump.out" "${file}.l"] } then {
13 fail $testname
14 verbose "output is [file_contents "dump.out"]" 2
15 return
16 }
17 send_log "$READELF $readelf_opts dump.o $readelf_pipe > dump.out\n"
18 set status [gas_host_run "$READELF $readelf_opts dump.o" ">readelf.out"]
19 if { [lindex $status 0] != 0 || ![string match "" [lindex $status 1]] } then {
20 send_log "[lindex $status 1]\n"
21 fail $testname
22 return
23 }
24 catch "exec cat readelf.out $readelf_pipe > dump.out\n" comp_output
25 if ![string match "" $comp_output] then {
26 send_log "$comp_output\n"
27 fail $testname
28 return
29 }
30 verbose_eval {[file_contents "dump.out"]} 3
31 if { [regexp_diff "dump.out" "${file}.e${suffix}"] } then {
32 fail $testname
33 verbose "output is [file_contents "dump.out"]" 2
34 return
35 }
36 pass $testname
37 }
38
39 # We're testing bits in obj-elf -- don't run on anything else.
40 if { ([istarget "*-*-*elf*"]
41 || [istarget "*-*-linux*"]
42 || [istarget "*-*-gnu*"]
43 || [istarget "m6811-*"]
44 || [istarget "m6812-*"]
45 || [istarget "sparc*-*-solaris*"]
46 || [istarget "mips*-*-irix6*"]
47 || [istarget "arm*-*-eabi"])
48 && ![istarget *-*-linux*aout*]
49 && ![istarget *-*-linux*coff*]
50 && ![istarget *-*-linux*oldld*]
51 && ![istarget sh64*-*-linux*]
52 } then {
53 set target_machine ""
54 if {[istarget "mips*-*-*"]} then {
55 set target_machine -mips
56 }
57 if {[istarget m32r*-*-*]} then {
58 set target_machine -m32r
59 }
60 if {[istarget "score-*-*"]} then {
61 set target_machine -score
62 }
63 if {[istarget "tic6x-*-*"]} then {
64 set target_machine -tic6x
65 }
66 if {[istarget "xtensa*-*-*"]} then {
67 set target_machine -xtensa
68 }
69 if {[istarget "rx-*-*"]} then {
70 set target_machine -rx
71 }
72 if {[istarget "arm*-*-*"]} {
73
74 if { ([istarget "*-*-*eabi"]
75 || [istarget "*-*-linux-*"]
76 || [istarget "*-*-symbianelf"])} then {
77 set target_machine -armeabi
78 } else {
79 set target_machine -armelf
80 }
81 }
82
83 # The MN10300 and Xtensa ports disable the assembler's call frame
84 # optimization because it interfers with link-time relaxation of
85 # function prologues.
86 if {![istarget "mn10300-*-*"]
87 && ![istarget "xtensa*-*-*"]
88 && ![istarget "am3*-*-*"]} then {
89 run_dump_test "ehopt0"
90 }
91 case $target_triplet in {
92 { m68k-*-* m68[03]??-*-* } {
93 run_dump_test "file" { { as "--defsym m68k=1" } }
94 }
95 { mmix-*-* } {
96 run_dump_test "file" { { as "--defsym mmix=1" } }
97 }
98 { xtensa*-*-* } {
99 run_dump_test "file" { { as "--rename-section file.s=file.c" } }
100 }
101 default {
102 run_dump_test "file"
103 }
104 }
105 run_dump_test "group0a"
106 run_dump_test "group0b"
107 run_dump_test "group0c"
108 run_dump_test "group1a"
109 run_dump_test "group1b"
110 run_dump_test "groupautoa"
111 case $target_triplet in {
112 { xtensa*-*-* } { }
113 default {
114 run_dump_test "groupautob"
115 }
116 }
117 case $target_triplet in {
118 { alpha*-*-* } { }
119 { cr16*-*-* } { }
120 { crx*-*-* } { }
121 { h8300-*-* } { }
122 { hppa*-*-* } { }
123 { iq2000*-*-* } { }
124 { mips*-*-* } { }
125 { mn10200-*-* } { }
126 { mn10300-*-* } { }
127 { *c54x*-*-* } { }
128 { rx-*-* } { }
129 default {
130 # The next test can fail if the target does not convert fixups
131 # against ordinary symbols into relocations against section symbols.
132 # This is usually revealed by the error message:
133 # symbol `sym' required but not present
134 run_dump_test redef
135 run_dump_test equ-reloc
136 }
137 }
138 run_dump_test "pseudo"
139 run_dump_test "section0"
140 run_dump_test "section1"
141 if {! [istarget "h8300-*-*"]} then {
142 # The h8300 port issues a warning message for
143 # new sections created without atrributes.
144 run_elf_list_test "section2" "$target_machine" "-al" "-s" ""
145 }
146 run_dump_test "section3"
147 run_dump_test "section4"
148 if {! [istarget "h8300-*-*"] && ! [istarget "rx-*-*"]} then {
149 # The h8300 port issues a warning message for
150 # new sections created without atrributes.
151 # The RX port does not complain about changing the attributes of the
152 # .data and .bss sections since it does not use those names.
153 run_elf_list_test "section5" "" "-al" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
154 }
155 run_dump_test "struct"
156 if { ![istarget "alpha*-*-*"] } then {
157 # The alpha port uses .set for state, e.g. nomacro.
158 run_dump_test "symtab"
159 }
160 run_dump_test "symver"
161
162 # The MSP port sets the ELF header's OSABI field to ELFOSABI_STANDALONE.
163 # The non-eabi ARM ports sets it to ELFOSABI_ARM.
164 # So for these targets we cannot include an IFUNC symbol type
165 # in the symbol type test.
166 if { [istarget "msp*-*-*"]
167 || [istarget "arm*-*-*"]} then {
168 run_elf_list_test "type-noifunc" "" "" "-s" "| grep \"1 *\\\[FONTC\\\]\""
169 } else {
170 run_dump_test ifunc-1
171 run_elf_list_test "type" "" "" "-s" "| grep \"1 *\\\[FIONTCU\\\]\""
172 }
173
174 run_dump_test "section6"
175 run_dump_test "section7"
176 run_dump_test "section8"
177 run_dump_test "section9"
178 run_dump_test "dwarf2-1"
179 run_dump_test "dwarf2-2"
180 run_dump_test "dwarf2-3"
181 run_dump_test "dwarf2-4"
182 run_dump_test "bad-section-flag"
183 run_dump_test "bad-size"
184 run_dump_test "bad-group"
185
186 load_lib gas-dg.exp
187 dg-init
188 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
189 dg-finish
190
191 }