x86: Use individual prefix control for each opcode.
[deliverable/binutils-gdb.git] / binutils / testsuite / binutils-all / objdump.exp
CommitLineData
b90efa5b 1# Copyright (C) 1993-2015 Free Software Foundation, Inc.
252b5132
RH
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
32866df7 5# the Free Software Foundation; either version 3 of the License, or
252b5132 6# (at your option) any later version.
65951855 7#
252b5132
RH
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.
65951855 12#
252b5132
RH
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
b43b5d5f 15# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
252b5132
RH
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-dejagnu@prep.ai.mit.edu
19
20# This file was written by Rob Savoye <rob@cygnus.com>
21# and rewritten by Ian Lance Taylor <ian@cygnus.com>
22
23if ![is_remote host] {
24 if {[which $OBJDUMP] == 0} then {
25 perror "$OBJDUMP does not exist"
26 return
27 }
28}
29
30send_user "Version [binutil_version $OBJDUMP]"
31
32# Simple test of objdump -i
33
34set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -i"]
35
41f5a528 36set cpus_expected [list]
a06ea964 37lappend cpus_expected aarch64 alpha arc arm cris
7c3f9ad0 38lappend cpus_expected d10v d30v fr30 fr500 fr550 h8 hppa i386 i860 i960 ip2022
e3cb57c3 39lappend cpus_expected m16c m32c m32r m68hc11 m68hc12 m68k m88k MCore MicroBlaze
73589c9d
CS
40lappend cpus_expected mips mn10200 mn10300 ms1 msp MSP430 nds32 n1h_v3 ns32k
41lappend cpus_expected or1k or1knd pj powerpc pyramid romp rs6000 s390 sh sparc
fb6cedde
WL
42lappend cpus_expected tahoe tic54x tic80 tilegx tms320c30 tms320c4x tms320c54x
43lappend cpus_expected v850 vax we32k x86-64 xscale xtensa z8k z8001 z8002
252b5132
RH
44
45# Make sure the target CPU shows up in the list.
41f5a528
FCE
46lappend cpus_expected ${target_cpu}
47
48# Create regexp
49set cpus_regex "([join $cpus_expected | ])"
50
51verbose -log "CPU regex: $cpus_regex"
252b5132 52
41f5a528 53set want "BFD header file version.*srec\[^\n\]*\n\[^\n\]*header \[^\n\]*endian\[^\n\]*, data \[^\n\]*endian.*$cpus_regex"
252b5132
RH
54
55if [regexp $want $got] then {
56 pass "objdump -i"
57} else {
58 fail "objdump -i"
59}
60
61# The remaining tests require a test file.
62
63
64if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
65 return
66}
67if [is_remote host] {
68 set testfile [remote_download host tmpdir/bintest.o]
69} else {
70 set testfile tmpdir/bintest.o
71}
72
73# Test objdump -f
74
75set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f $testfile"]
76
41f5a528 77set want "$testfile:\[ \]*file format.*architecture:\[ \]*${cpus_regex}.*HAS_RELOC.*HAS_SYMS"
252b5132
RH
78
79if ![regexp $want $got] then {
80 fail "objdump -f"
81} else {
82 pass "objdump -f"
83}
84
85# Test objdump -h
86
87set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h $testfile"]
88
89set want "$testfile:\[ \]*file format.*Sections.*\[0-9\]+\[ \]+\[^ \]*(text|TEXT|\\\$CODE\\\$)\[^ \]*\[ \]*(\[0-9a-fA-F\]+).*\[0-9\]+\[ \]+\[^ \]*(\\.data|DATA)\[^ \]*\[ \]*(\[0-9a-fA-F\]+)"
90
91if ![regexp $want $got all text_name text_size data_name data_size] then {
92 fail "objdump -h"
93} else {
94 verbose "text name is $text_name size is $text_size"
95 verbose "data name is $data_name size is $data_size"
60bcf0fa
NC
96 set ets 8
97 set eds 4
48c5eb8a
SS
98 # The [ti]c4x target has the property sizeof(char)=sizeof(long)=1
99 if [istarget *c4x*-*-*] then {
100 set ets 2
101 set eds 1
102 }
60bcf0fa
NC
103 # c54x section sizes are in bytes, not octets; adjust accordingly
104 if [istarget *c54x*-*-*] then {
105 set ets 4
106 set eds 2
107 }
108 if {[expr "0x$text_size"] < $ets || [expr "0x$data_size"] < $eds} then {
252b5132
RH
109 send_log "sizes too small\n"
110 fail "objdump -h"
111 } else {
112 pass "objdump -h"
113 }
114}
115
116# Test objdump -t
117
118set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -t $testfile"]
119
120if [info exists vars] then { unset vars }
121while {[regexp "(\[a-z\]*_symbol)(.*)" $got all symbol rest]} {
122 set vars($symbol) 1
123 set got $rest
124}
125
126if {![info exists vars(text_symbol)] \
127 || ![info exists vars(data_symbol)] \
128 || ![info exists vars(common_symbol)] \
129 || ![info exists vars(external_symbol)]} then {
130 fail "objdump -t"
131} else {
132 pass "objdump -t"
133}
134
135# Test objdump -r
136
137set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $testfile"]
138
139set want "$testfile:\[ \]*file format.*RELOCATION RECORDS FOR \\\[\[^\]\]*(text|TEXT|\\\$CODE\\\$)\[^\]\]*\\\].*external_symbol"
140
141if [regexp $want $got] then {
142 pass "objdump -r"
143} else {
144 fail "objdump -r"
145}
146
147# Test objdump -s
148
149set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s $testfile"]
150
60bcf0fa 151set want "$testfile:\[ \]*file format.*Contents.*(text|TEXT|\\\$CODE\\\$)\[^0-9\]*\[ \]*\[0-9a-fA-F\]*\[ \]*(00000001|01000000|00000100).*Contents.*(data|DATA)\[^0-9\]*\[ \]*\[0-9a-fA-F\]*\[ \]*(00000002|02000000|00000200)"
252b5132
RH
152
153if [regexp $want $got] then {
154 pass "objdump -s"
155} else {
156 fail "objdump -s"
157}
158
1b315056
CS
159# Test objdump -s on a file that contains a compressed .debug section
160
65951855 161if { ![is_elf_format] || ![is_zlib_supported] } then {
22bce68e
AM
162 unsupported "objdump compressed debug"
163} elseif { ![binutils_assemble $srcdir/$subdir/dw2-compressed.S tmpdir/dw2-compressed.o] } then {
164 fail "objdump compressed debug"
1b315056 165} else {
22bce68e
AM
166 if [is_remote host] {
167 set compressed_testfile [remote_download host tmpdir/dw2-compressed.o]
168 } else {
169 set compressed_testfile tmpdir/dw2-compressed.o
170 }
1b315056 171
22bce68e 172 set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -s -j .zdebug_abbrev $compressed_testfile" "" "/dev/null" "objdump.out"]
1b315056 173
22bce68e
AM
174 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
175 fail "objdump -s -j .zdebug_abbrev (reason: unexpected output)"
176 send_log $got
177 send_log "\n"
178 }
1b315056 179
22bce68e
AM
180 if { [regexp_diff objdump.out $srcdir/$subdir/objdump.s] } then {
181 fail "objdump -s -j .zdebug_abbrev"
182 } else {
183 pass "objdump -s -j .zdebug_abbrev"
184 }
1b315056 185
22bce68e 186 # Test objdump -W on a file that contains some compressed .debug sections
1b315056 187
22bce68e 188 set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -W $compressed_testfile" "" "/dev/null" "objdump.out"]
1b315056 189
22bce68e
AM
190 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
191 fail "objdump -W (reason: unexpected output)"
192 send_log $got
193 send_log "\n"
194 }
1b315056 195
22bce68e
AM
196 if { [regexp_diff objdump.out $srcdir/$subdir/objdump.W] } then {
197 fail "objdump -W"
198 } else {
199 pass "objdump -W"
200 }
1b315056
CS
201}
202
4eee63bc 203# Test objdump -WL on a file that contains line information for multiple files and search directories.
73589c9d 204# Not supported on mcore and moxie targets because they do not (yet) support the generation
e3cb57c3
NC
205# of DWARF2 line debug information.
206
207if { ![is_elf_format]
71ac97b2
AM
208 || [istarget "hppa64*-*-hpux*"]
209 || [istarget "i370-*-*"]
210 || [istarget "i960-*-*"]
e3cb57c3
NC
211 || [istarget "ia64*-*-*"]
212 || [istarget "mcore-*-*"]
213 || [istarget "moxie-*-*"]
e3cb57c3 214} then {
d4cb0ea0 215 unsupported "objump decode line"
4eee63bc 216} else {
73589c9d
CS
217 if { [istarget "or1k*-*-*"] } then {
218 set decodedline_testsrc $srcdir/$subdir/dw2-decodedline-1.S
219 } else {
220 set decodedline_testsrc $srcdir/$subdir/dw2-decodedline.S
221 }
222 if { ![binutils_assemble $decodedline_testsrc tmpdir/dw2-decodedline.o] } then {
d4cb0ea0
NC
223 fail "objdump decoded line"
224 }
225
226 if [is_remote host] {
227 set decodedline_testfile [remote_download host tmpdir/dw2-decodedline.o]
228 } else {
229 set decodedline_testfile tmpdir/dw2-decodedline.o
230 }
4eee63bc 231
d4cb0ea0 232 set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -WL $decodedline_testfile" "" "/dev/null" "objdump.out"]
4eee63bc 233
d4cb0ea0
NC
234 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
235 fail "objdump -WL (reason: unexpected output)"
236 send_log $got
237 send_log "\n"
238 }
4eee63bc 239
d4cb0ea0
NC
240 if { [regexp_diff objdump.out $srcdir/$subdir/objdump.WL] } then {
241 fail "objdump -WL"
242 } else {
243 pass "objdump -WL"
244 }
4eee63bc 245}
1b315056 246
252b5132
RH
247# Options which are not tested: -a -d -D -R -T -x -l --stabs
248# I don't see any generic way to test any of these other than -a.
249# Tests could be written for specific targets, and that should be done
250# if specific problems are found.
This page took 0.653052 seconds and 4 git commands to generate.