3071ec398bb6b703fc43a59eae8b864c28605373
[external/binutils.git] / gas / testsuite / gas / cfi / cfi.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 if { ![is_elf_format] && ![is_pecoff_format] } then {
19     return
20 }
21
22 proc gas_x86_64_check { } {
23     global NM
24     global NMFLAGS
25
26     set status [gas_host_run "$NM $NMFLAGS --help" ""]
27     return [regexp "targets:.*x86-64" [lindex $status 1]];
28 }
29
30 proc gas_x86_32_check { } {
31     global NM
32     global NMFLAGS
33
34     set status [gas_host_run "$NM $NMFLAGS --help" ""]
35     return [regexp "targets:.*i386" [lindex $status 1]];
36 }
37
38 if  { [istarget "i*86-*-*"] || [istarget "x86_64-*-*"] } then {
39
40     global ASFLAGS
41     set old_ASFLAGS "$ASFLAGS"
42
43     if { [gas_x86_64_check] } then {
44         set ASFLAGS "$ASFLAGS --64"
45         run_dump_test "cfi-x86_64"
46         set ASFLAGS "$old_ASFLAGS"
47     }
48
49     if { [gas_x86_32_check] }  then {
50         set ASFLAGS "$ASFLAGS --32"
51         run_dump_test "cfi-i386"
52         set ASFLAGS "$old_ASFLAGS"
53     }
54
55     if { [is_pecoff_format] } then {
56         run_dump_test "reloc-pe-i386"
57     }
58
59 } elseif { [istarget alpha*-*-*] } then {
60     run_dump_test "cfi-alpha-1"
61     run_dump_test "cfi-alpha-2"
62     run_dump_test "cfi-alpha-3"
63
64 } elseif { [istarget powerpc*-*-*] } then {
65     run_dump_test "cfi-ppc-1"
66
67 } elseif { [istarget s390*-*-*] } then {
68     run_dump_test "cfi-s390-1"
69     if { [istarget s390x*-*-*] } then {
70         run_dump_test "cfi-s390x-1"
71     }
72
73 } elseif { [istarget "m68*-*"] } then {
74     run_dump_test "cfi-m68k"
75
76 } elseif { [istarget sparc*-*-*] } then {
77     global NM
78     global NMFLAGS
79
80     set nm_status [gas_host_run "$NM $NMFLAGS --help" ""]
81     run_dump_test "cfi-sparc-1"
82     if { [regexp "elf64\[_-\]sparc" [lindex $nm_status 1]] } then {
83         run_dump_test "cfi-sparc64-1"
84     }
85
86 } elseif [istarget "sh*-*"] then {
87     if { [istarget sh64*-*-*] || [istarget sh5*-*-*] } then {
88     } else {
89         run_dump_test "cfi-sh-1"
90     }
91
92 } elseif { [istarget "arm*-*"] } then {
93     # Only ELF based ARM targets support CFI.
94     if { [is_pecoff_format] } then {
95         return
96     }
97     run_dump_test "cfi-arm-1"
98
99 } elseif { [istarget "mips*-*"] } then {
100     run_dump_test "cfi-mips-1"
101 } elseif { [istarget "hppa*-linux*"] } then {
102     run_dump_test "cfi-hppa-1"
103 } else {
104     return
105 }
106
107 run_list_test "cfi-diag-1" ""
108
109 # HPPA64 uses 64-bit relocations, which results in all of the dump
110 # offset numbers not matching up.
111 if { ![istarget "hppa64*-*"] } then {
112   run_dump_test "cfi-common-1"
113   run_dump_test "cfi-common-2"
114   run_dump_test "cfi-common-3"
115   run_dump_test "cfi-common-4"
116   if { ![is_pecoff_format] } then {
117     # This test uses .subsection/.previous which are elf-specific.
118     run_dump_test "cfi-common-5"
119   }
120   # Some targets don't support PC relative cfi directives
121   if { ![istarget "mips*-*"] &&
122        !([istarget powerpc*-*-*] && [is_pecoff_format]) } then {
123     run_dump_test "cfi-common-6"
124   }
125   run_dump_test "cfi-common-7"
126 }