91a5e9b079147d87ec5c60a2f975d31e02a8395a
[external/binutils.git] / gas / testsuite / gas / i386 / i386.exp
1 #
2 # i386 tests
3 #
4 proc run_list_test { name opts } {
5     global srcdir subdir
6     set testname "i386 $name"
7     set file $srcdir/$subdir/$name
8     gas_run ${name}.s $opts ">&dump.out"
9     if { [regexp_diff "dump.out" "${file}.l"] } then {
10         fail $testname
11         verbose "output is [file_contents "dump.out"]" 2
12         return
13     }
14     pass $testname
15 }
16
17 proc gas_64_check { } {
18     global NM
19     global NMFLAGS
20     global srcdir
21
22     catch "exec $srcdir/lib/run $NM $NMFLAGS --help" nm_help
23     return [regexp "targets:.*x86-64" $nm_help]
24 }
25
26 proc gas_32_check { } {
27     global NM
28     global NMFLAGS
29     global srcdir
30
31     catch "exec $srcdir/lib/run $NM $NMFLAGS --help" nm_help
32     return [regexp "targets:.*i386" $nm_help]
33 }
34
35 if [expr ([istarget "i*86-*-*"] ||  [istarget "x86_64-*-*"]) && [gas_32_check]]  then {
36
37     global ASFLAGS
38     set old_ASFLAGS "$ASFLAGS"
39     set ASFLAGS "$ASFLAGS --32"
40
41     run_list_test "float" "-al"
42     run_list_test "general" "-al --listing-lhs-width=2"
43     run_list_test "inval" "-al"
44     run_list_test "segment" "-al"
45     run_list_test "inval-seg" "-al"
46     run_list_test "modrm" "-al --listing-lhs-width=2"
47     run_dump_test "naked"
48     run_dump_test "opcode"
49     run_dump_test "intel"
50     run_dump_test "intel16"
51     run_list_test "intelbad" ""
52     run_dump_test "intelok"
53     run_dump_test "prefix"
54     run_dump_test "amd"
55     run_dump_test "katmai"
56     run_dump_test "jump"
57     run_dump_test "ssemmx2"
58     run_dump_test "sse2"
59     run_dump_test "sub"
60     run_dump_test "prescott"
61     run_dump_test "sib"
62     run_dump_test "vmx"
63     run_dump_test "suffix"
64     run_dump_test "immed32"
65     run_dump_test "equ"
66     run_dump_test "divide"
67     run_dump_test "padlock"
68     run_dump_test "crx"
69     run_list_test "cr-err" ""
70     run_dump_test "svme"
71
72     # These tests require support for 8 and 16 bit relocs,
73     # so we only run them for ELF and COFF targets.
74     if {[is_elf_format] || [istarget "*-*-coff*"]} then {
75         run_dump_test "reloc"
76         run_dump_test "jump16"
77         run_list_test "white" "-al --listing-lhs-width=3"
78
79         # These tests should in theory work for PE targets as well,
80         # but the relocs we currently produce are slightly different
81         # from those produced for ELF/COFF based toolchains.
82         # So for now we ignore PE targets.
83         run_dump_test "pcrel"
84         run_dump_test "absrel"
85     }
86
87     # ELF specific tests
88     if [is_elf_format] then {
89         # PIC is only supported on ELF targets.
90         run_dump_test "intelpic"
91
92         run_dump_test "relax"
93         run_dump_test "gotpc"
94         run_dump_test "tlsd"
95         run_dump_test "tlspic"
96         run_dump_test "tlsnopic"
97         run_dump_test "bss"
98         run_dump_test "reloc32"
99         run_list_test "reloc32" "--defsym _bad_=1"
100         run_dump_test "mixed-mode-reloc32"
101     }
102
103     # This is a PE specific test.
104     if { [istarget "*-*-cygwin*"] || [istarget "*-*-pe"]
105          || [istarget "*-*-mingw*"]
106     } then {
107         run_dump_test "secrel"
108     }
109
110     set ASFLAGS "$old_ASFLAGS"
111 }
112
113 if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] then {
114
115     global ASFLAGS
116     set old_ASFLAGS "$ASFLAGS"
117     set ASFLAGS "$ASFLAGS --64"
118
119     run_dump_test "x86_64"
120     run_dump_test "x86-64-addr32"
121     run_dump_test "x86-64-opcode"
122     run_dump_test "x86-64-pcrel"
123     run_dump_test "x86-64-rip"
124     run_dump_test "x86-64-stack"
125     run_dump_test "x86-64-stack-intel"
126     run_dump_test "x86-64-stack-suffix"
127     run_list_test "x86-64-inval" "-al"
128     run_list_test "x86-64-segment" "-al"
129     run_list_test "x86-64-inval-seg" "-al"
130     run_dump_test "x86-64-branch"
131     run_dump_test "svme64"
132     run_dump_test "x86-64-vmx"
133     run_dump_test "immed64"
134     run_dump_test "x86-64-prescott"
135     run_dump_test "x86-64-crx"
136     run_dump_test "x86-64-crx-suffix"
137
138     if { ![istarget "*-*-aix*"]
139       && ![istarget "*-*-beos*"]
140       && ![istarget "*-*-*bsd*"]
141       && ![istarget "*-*-chaos*"]
142       && ![istarget "*-*-kaos*"]
143       && ![istarget "*-*-lynx*"]
144       && ![istarget "*-*-moss*"]
145       && ![istarget "*-*-nto-qnx*"]
146       && ![istarget "*-*-rtems*"]
147       && ![istarget "*-*-sco*"]
148       && ![istarget "*-*-solaris*"]
149       && ![istarget "*-*-sysv*"] } then {
150         run_dump_test "rex"
151     }
152
153     # For ELF targets verify that @unwind works.
154     if { ([istarget "*-*-elf*"] || [istarget "*-*-linux*"]
155           || [istarget "*-*-solaris2.*"])
156          && ![istarget *-*-linux*aout*]
157          && ![istarget *-*-linux*oldld*] } then {
158         run_dump_test "x86-64-unwind"
159     }
160
161     # ELF specific tests
162     if [is_elf_format] then {
163         run_dump_test "reloc64"
164         run_list_test "reloc64" "--defsym _bad_=1"
165         run_dump_test "mixed-mode-reloc64"
166     }
167
168     set ASFLAGS "$old_ASFLAGS"
169 }