Add copyright notices
[deliverable/binutils-gdb.git] / gas / testsuite / gas / elf / elf.exp
1 # Copyright 2012
2 # Free Software Foundation, Inc.
3
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.
8 #
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.
13 #
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.
17
18 #
19 # elf tests
20 #
21
22 proc run_elf_list_test { name suffix opts readelf_opts readelf_pipe } {
23 global READELF
24 global srcdir subdir
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 {
30 fail $testname
31 verbose "output is [file_contents "dump.out"]" 2
32 return
33 }
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"
38 fail $testname
39 return
40 }
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"
44 fail $testname
45 return
46 }
47 verbose_eval {[file_contents "dump.out"]} 3
48 if { [regexp_diff "dump.out" "${file}.e${suffix}"] } then {
49 fail $testname
50 verbose "output is [file_contents "dump.out"]" 2
51 return
52 }
53 pass $testname
54 }
55
56 # We're testing bits in obj-elf -- don't run on anything else.
57 if { [is_elf_format] } then {
58 set target_machine ""
59 if {[istarget "mips*-*-*"]} then {
60 set target_machine -mips
61 }
62 if {[istarget m32r*-*-*]} then {
63 set target_machine -m32r
64 }
65 if {[istarget "score-*-*"]} then {
66 set target_machine -score
67 }
68 if {[istarget "tic6x-*-*"]} then {
69 set target_machine -tic6x
70 }
71 if {[istarget "xtensa*-*-*"]} then {
72 set target_machine -xtensa
73 }
74 if {[istarget "rx-*-*"]} then {
75 set target_machine -rx
76 }
77 if {[istarget "arm*-*-*"]} {
78
79 if { ([istarget "*-*-*eabi"]
80 || [istarget "*-*-linux-*"]
81 || [istarget "*-*-nacl*"]
82 || [istarget "*-*-symbianelf"])} then {
83 set target_machine -armeabi
84 } else {
85 set target_machine -armelf
86 }
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 "am3*-*-*"]} then {
95 run_dump_test "ehopt0"
96 }
97 case $target_triplet in {
98 { m68k-*-* m68[03]??-*-* } {
99 run_dump_test "file" { { as "--defsym m68k=1" } }
100 }
101 { mmix-*-* } {
102 run_dump_test "file" { { as "--defsym mmix=1" } }
103 }
104 { xtensa*-*-* } {
105 run_dump_test "file" { { as "--rename-section file.s=file.c" } }
106 }
107 default {
108 run_dump_test "file"
109 }
110 }
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* } { }
118 default {
119 run_dump_test "groupautoa"
120 }
121 }
122 case $target_triplet in {
123 { hppa64*-*-hpux* } { }
124 { xtensa*-*-* } { }
125 default {
126 run_dump_test "groupautob"
127 }
128 }
129 case $target_triplet in {
130 { alpha*-*-* } { }
131 { cr16*-*-* } { }
132 { crx*-*-* } { }
133 { h8300-*-* } { }
134 { hppa*-*-* } { }
135 { iq2000*-*-* } { }
136 { mips*-*-* } { }
137 { mn10200-*-* } { }
138 { mn10300-*-* } { }
139 { *c54x*-*-* } { }
140 { rx-*-* } { }
141 default {
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*-*-*"
147 run_dump_test redef
148 run_dump_test equ-reloc
149 }
150 }
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" ""
158 }
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\\\]\""
167 }
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"
172 }
173 run_dump_test "symver"
174
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\\\]\""
186 }
187 } else {
188 run_dump_test ifunc-1
189 run_elf_list_test "type" "" "" "-s" "| grep \"1 *\\\[FIONTCU\\\]\""
190 }
191
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"
203
204 run_dump_test "syms"
205
206 run_dump_test "common1"
207 run_dump_test "common2"
208
209 load_lib gas-dg.exp
210 dg-init
211 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
212 dg-finish
213
214 }
This page took 0.123651 seconds and 5 git commands to generate.