1 # Copyright (C) 1993-2015 Free Software Foundation, Inc.
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.
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.
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.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-dejagnu@prep.ai.mit.edu
20 # This file was written by Rob Savoye <rob@cygnus.com>
21 # and rewritten by Ian Lance Taylor <ian@cygnus.com>
23 if ![is_remote host] {
24 if {[which $OBJDUMP] == 0} then {
25 perror "$OBJDUMP does not exist"
30 send_user "Version [binutil_version $OBJDUMP]"
32 # Simple test of objdump -i
34 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -i"]
36 set cpus_expected [list]
37 lappend cpus_expected aarch64 alpha arc arm cris
38 lappend cpus_expected d10v d30v fr30 fr500 fr550 h8 hppa i386 i860 i960 iamcu ip2022
39 lappend cpus_expected m16c m32c m32r m68hc11 m68hc12 m68k m88k MCore mep c5 h1 MicroBlaze
40 lappend cpus_expected mips mn10200 mn10300 ms1 msp MSP430 nds32 n1h_v3 ns32k
41 lappend cpus_expected or1k or1knd pj powerpc pyramid romp rs6000 s390 sh sparc
42 lappend cpus_expected tahoe tic54x tic80 tilegx tms320c30 tms320c4x tms320c54x
43 lappend cpus_expected v850 vax we32k x86-64 xscale xtensa z8k z8001 z8002
45 # Make sure the target CPU shows up in the list.
46 lappend cpus_expected ${target_cpu}
49 set cpus_regex "([join $cpus_expected | ])"
51 verbose -log "CPU regex: $cpus_regex"
53 set want "BFD header file version.*srec\[^\n\]*\n\[^\n\]*header \[^\n\]*endian\[^\n\]*, data \[^\n\]*endian.*$cpus_regex"
55 if [regexp $want $got] then {
61 # The remaining tests require a test file.
64 if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
68 set testfile [remote_download host tmpdir/bintest.o]
70 set testfile tmpdir/bintest.o
75 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f $testfile"]
77 set want "$testfile:\[ \]*file format.*architecture:\[ \]*${cpus_regex}.*HAS_RELOC.*HAS_SYMS"
79 if ![regexp $want $got] then {
87 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h $testfile"]
89 set want "$testfile:\[ \]*file format.*Sections.*\[0-9\]+\[ \]+\[^ \]*(text|TEXT|\\\$CODE\\\$)\[^ \]*\[ \]*(\[0-9a-fA-F\]+).*\[0-9\]+\[ \]+\[^ \]*(\\.data|DATA)\[^ \]*\[ \]*(\[0-9a-fA-F\]+)"
91 if ![regexp $want $got all text_name text_size data_name data_size] then {
94 verbose "text name is $text_name size is $text_size"
95 verbose "data name is $data_name size is $data_size"
98 # The [ti]c4x target has the property sizeof(char)=sizeof(long)=1
99 if [istarget *c4x*-*-*] then {
103 # c54x section sizes are in bytes, not octets; adjust accordingly
104 if [istarget *c54x*-*-*] then {
108 if {[expr "0x$text_size"] < $ets || [expr "0x$data_size"] < $eds} then {
109 send_log "sizes too small\n"
118 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -t $testfile"]
120 if [info exists vars] then { unset vars }
121 while {[regexp "(\[a-z\]*_symbol)(.*)" $got all symbol rest]} {
126 if {![info exists vars(text_symbol)] \
127 || ![info exists vars(data_symbol)] \
128 || ![info exists vars(common_symbol)] \
129 || ![info exists vars(external_symbol)]} then {
137 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $testfile"]
139 set want "$testfile:\[ \]*file format.*RELOCATION RECORDS FOR \\\[\[^\]\]*(text|TEXT|\\\$CODE\\\$)\[^\]\]*\\\].*external_symbol"
141 if [regexp $want $got] then {
149 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s $testfile"]
151 set 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)"
153 if [regexp $want $got] then {
159 # Test objdump -s on a file that contains a compressed .debug section
161 if { ![is_elf_format] } then {
162 unsupported "objdump compressed debug"
163 } elseif { ![binutils_assemble $srcdir/$subdir/dw2-compressed.S tmpdir/dw2-compressed.o] } then {
164 fail "objdump compressed debug"
166 if [is_remote host] {
167 set compressed_testfile [remote_download host tmpdir/dw2-compressed.o]
169 set compressed_testfile tmpdir/dw2-compressed.o
172 set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -s -j .zdebug_abbrev $compressed_testfile" "" "/dev/null" "objdump.out"]
174 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
175 fail "objdump -s -j .zdebug_abbrev (reason: unexpected output)"
180 if { [regexp_diff objdump.out $srcdir/$subdir/objdump.s] } then {
181 fail "objdump -s -j .zdebug_abbrev"
183 pass "objdump -s -j .zdebug_abbrev"
186 # Test objdump -W on a file that contains some compressed .debug sections
188 set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -W $compressed_testfile" "" "/dev/null" "objdump.out"]
190 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
191 fail "objdump -W (reason: unexpected output)"
196 if { [regexp_diff objdump.out $srcdir/$subdir/objdump.W] } then {
203 # Test objdump -WL on a file that contains line information for multiple files and search directories.
204 # Not supported on mcore and moxie targets because they do not (yet) support the generation
205 # of DWARF2 line debug information.
207 if { ![is_elf_format]
208 || [istarget "hppa64*-*-hpux*"]
209 || [istarget "i370-*-*"]
210 || [istarget "i960-*-*"]
211 || [istarget "ia64*-*-*"]
212 || [istarget "mcore-*-*"]
213 || [istarget "moxie-*-*"]
215 unsupported "objump decode line"
217 if { [istarget "or1k*-*-*"] } then {
218 set decodedline_testsrc $srcdir/$subdir/dw2-decodedline-1.S
220 set decodedline_testsrc $srcdir/$subdir/dw2-decodedline.S
222 if { ![binutils_assemble $decodedline_testsrc tmpdir/dw2-decodedline.o] } then {
223 fail "objdump decoded line"
226 if [is_remote host] {
227 set decodedline_testfile [remote_download host tmpdir/dw2-decodedline.o]
229 set decodedline_testfile tmpdir/dw2-decodedline.o
232 set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -WL $decodedline_testfile" "" "/dev/null" "objdump.out"]
234 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
235 fail "objdump -WL (reason: unexpected output)"
240 if { [regexp_diff objdump.out $srcdir/$subdir/objdump.WL] } then {
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.