1#   Copyright (C) 2004-2020 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
17if {![istarget "arm*-*-*"]} then {
18  return
19}
20
21if {![is_remote host] && [which $OBJDUMP] == 0} then {
22    perror "$OBJDUMP does not exist"
23    return
24}
25
26send_user "Version [binutil_version $OBJDUMP]"
27
28###########################
29# Set up the test of movem.s
30###########################
31
32if {![binutils_assemble $srcdir/$subdir/thumb2-cond.s tmpdir/thumb2-cond.o]} then {
33    fail "thumb2-cond (assembling)"
34} else {
35
36    if [is_remote host] {
37	set objfile [remote_download host tmpdir/thumb2-cond.o]
38    } else {
39	set objfile tmpdir/thumb2-cond.o
40    }
41
42    # Make sure that conditional instructions are correctly decoded.
43
44    set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble --start-address=6 $objfile"]
45
46    set want "bcc.w\[ \t\]*e12.*bx\[ \t\]*lr"
47
48    if [regexp $want $got] then {
49	pass "thumb2-cond test1"
50    } else {
51	fail "thumb2-cond test1"
52    }
53
54    set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble --start-address=10 $objfile"]
55
56    set want "bx\[ \t\]*lr"
57
58    if [regexp $want $got] then {
59	pass "thumb2-cond test2"
60    } else {
61	fail "thumb2-cond test2"
62    }
63}
64
65###########################
66# Set up the test of multiple disassemblies
67###########################
68
69if {![binutils_assemble $srcdir/$subdir/simple.s tmpdir/simple.o]} then {
70    fail "multiple input files"
71} else {
72
73    if [is_remote host] {
74	set objfile [remote_download host tmpdir/simple.o]
75    } else {
76	set objfile tmpdir/simple.o
77    }
78
79    # Make sure multiple disassemblies come out the same
80
81    set got [binutils_run $OBJDUMP "-dr $objfile $objfile"]
82
83    set want "$objfile:\[ \]*file format.*$objfile:\[ \]*file format.*push.*add.*sub.*str.*add.*ldmfd"
84
85    if [regexp $want $got] then {
86	pass "multiple input files"
87    } else {
88	fail "multiple input files"
89    }
90}
91
92if {![binutils_assemble $srcdir/$subdir/rvct_symbol.s tmpdir/rvct_symbol.o]} then {
93    fail "skip rvct symbol"
94} else {
95
96    if [is_remote host] {
97	set objfile [remote_download host tmpdir/rvct_symbol.o]
98    } else {
99	set objfile tmpdir/rvct_symbol.o
100    }
101
102    # Make sure multiple disassemblies come out the same
103
104    set got [binutils_run $OBJDUMP "-D $objfile $objfile"]
105
106    set want "foo.*global_a.*global_b"
107
108    if [regexp $want $got] then {
109	pass "skip rvct symbol"
110    } else {
111	fail "skip rvct symbol"
112    }
113}
114
115###########################
116# Set up generic test framework
117###########################
118
119set tempfile tmpdir/armtemp.o
120set copyfile tmpdir/armcopy
121
122set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
123foreach t $test_list {
124    # We need to strip the ".d", but can leave the dirname.
125    verbose [file rootname $t]
126    run_dump_test [file rootname $t]
127}
128