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