* archures.c: Add some more MSP430 machine numbers.
[external/binutils.git] / gas / testsuite / gas / elf / elf.exp
1 # Copyright 2012-2013 Free Software Foundation, Inc.
2
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.
7
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.
12
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.  
16
17 #
18 # elf tests
19 #
20
21 proc run_elf_list_test { name suffix opts readelf_opts readelf_pipe } {
22     global READELF
23     global srcdir subdir
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 {
29         fail $testname
30         verbose "output is [file_contents "dump.out"]" 2
31         return
32     }
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"
37         fail $testname
38         return
39     }
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"
43         fail $testname
44         return
45     }
46     verbose_eval {[file_contents "dump.out"]} 3
47     if { [regexp_diff "dump.out" "${file}.e${suffix}"] } then {
48         fail $testname
49         verbose "output is [file_contents "dump.out"]" 2
50         return
51     }
52     pass $testname
53 }
54
55 # We're testing bits in obj-elf -- don't run on anything else.
56 if { [is_elf_format] } then {
57     set target_machine ""
58     if {[istarget "mips*-*-*"]} then {
59         set target_machine -mips
60     }
61     if {[istarget m32r*-*-*]} then {
62         set target_machine -m32r
63     }
64     if {[istarget "msp430-*-*"]} then {
65         set target_machine -msp430
66     }
67     if {[istarget "score-*-*"]} then {
68         set target_machine -score
69     }
70     if {[istarget "tic6x-*-*"]} then {
71         set target_machine -tic6x
72     }
73     if {[istarget "xtensa*-*-*"]} then {
74         set target_machine -xtensa
75     }
76     if {[istarget "rx-*-*"]} then {
77         set target_machine -rx
78     }
79     if {[istarget "arm*-*-*"]} {
80
81         if { ([istarget "*-*-*eabi"]
82               || [istarget "*-*-linux-*"]
83               || [istarget "*-*-nacl*"]
84               || [istarget "*-*-symbianelf"])} then {
85             set target_machine -armeabi
86         } else {
87             set target_machine -armelf
88         }
89     }
90
91     # The MN10300 and Xtensa ports disable the assembler's call frame
92     # optimization because it interfers with link-time relaxation of
93     # function prologues.
94     if {![istarget "mn10300-*-*"]
95         && ![istarget "xtensa*-*-*"]
96         && ![istarget "msp430*-*-*"]
97         && ![istarget "am3*-*-*"]} then {
98       run_dump_test "ehopt0"
99     }
100     case $target_triplet in {
101         { m68k-*-* m68[03]??-*-* } {
102             run_dump_test "file" { { as "--defsym m68k=1" } }
103         }
104         { mmix-*-* } {
105             run_dump_test "file" { { as "--defsym mmix=1" } }
106         }
107         { xtensa*-*-* } {
108             run_dump_test "file" { { as "--rename-section file.s=file.c" } }
109         }
110         default {
111             run_dump_test "file"
112         }
113     }
114     run_dump_test "group0a"
115     run_dump_test "group0b"
116     run_dump_test "group0c"
117     run_dump_test "group1a"
118     run_dump_test "group1b"
119     case $target_triplet in {
120         { hppa64*-*-hpux* } { }
121         default {
122             run_dump_test "groupautoa"
123         }
124     }
125     case $target_triplet in {
126         { hppa64*-*-hpux* } { }
127         { xtensa*-*-* } { }
128         default {
129             run_dump_test "groupautob"
130         }
131     }
132     case $target_triplet in {
133         { alpha*-*-* } { }
134         { cr16*-*-* } { }
135         { crx*-*-* } { }
136         { h8300-*-* } { }
137         { hppa*-*-* } { }
138         { iq2000*-*-* } { }
139         { mips*-*-* } { }
140         { mn10200-*-* } { }
141         { mn10300-*-* } { }
142         { msp43*-*-* } { }
143         { *c54x*-*-* } { }
144         { rx-*-* } { }
145         default {
146             # The next test can fail if the target does not convert fixups
147             # against ordinary symbols into relocations against section symbols.
148             # This is usually revealed by the error message:
149             #  symbol `sym' required but not present
150         setup_xfail "m681*-*-*" "m68hc*-*-*"
151             run_dump_test redef
152             run_dump_test equ-reloc
153         }
154     }
155     run_dump_test "pseudo"
156     run_dump_test "section0"
157     run_dump_test "section1"
158     if {! [istarget "h8300-*-*"]} then {
159         # The h8300 port issues a warning message for
160         # new sections created without atrributes.
161         run_elf_list_test "section2" "$target_machine" "-al" "-s" ""
162     }
163     run_dump_test "section3"
164     run_dump_test "section4"
165     if {! [istarget "h8300-*-*"] && ! [istarget "rx-*-*"]} then {
166         # The h8300 port issues a warning message for
167         # new sections created without atrributes.
168         # The RX port does not complain about changing the attributes of the
169         # .data and .bss sections since it does not use those names.
170         run_elf_list_test "section5" "" "-al" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
171     }
172     run_dump_test "struct"
173     if { ![istarget "alpha*-*-*"] } then {
174         # The alpha port uses .set for state, e.g. nomacro.
175         run_dump_test "symtab"
176     }
177     run_dump_test "symver"
178
179     # No indirect functions on non-GNU targets.
180     # The MSP port sets the ELF header's OSABI field to ELFOSABI_STANDALONE.
181     # The non-eabi ARM ports sets it to ELFOSABI_ARM.
182     # So for these targets we cannot include an IFUNC symbol type
183     # in the symbol type test.
184     if { [istarget "*-*-hpux*"]
185          || [istarget "msp*-*-*"]
186          || [istarget "arm*-*-*"]} then {
187         # hppa64 has a non-standard common directive
188         if { ![istarget "hppa64*-*-hpux*"] } then {
189             run_elf_list_test "type-noifunc" "" "" "-s" "| grep \"1 *\\\[FONTC\\\]\""
190         }
191     } else {
192         run_dump_test ifunc-1
193         run_elf_list_test "type" "" "" "-s" "| grep \"1 *\\\[FIONTCU\\\]\""
194     }
195
196     run_dump_test "section6"
197     run_dump_test "section7"
198     run_dump_test "section8"
199     run_dump_test "section9"
200     run_dump_test "dwarf2-1"
201     run_dump_test "dwarf2-2"
202     run_dump_test "dwarf2-3"
203     run_dump_test "dwarf2-4"
204     run_dump_test "bad-section-flag"
205     run_dump_test "bad-size"
206     run_dump_test "bad-group"
207
208     run_dump_test "syms"
209     
210     run_dump_test "common1"
211     run_dump_test "common2"
212
213 load_lib gas-dg.exp
214 dg-init
215 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
216 dg-finish
217     
218 }