* binutils-all/ar.exp: Remove stray semicolons.
[deliverable/binutils-gdb.git] / binutils / testsuite / binutils-all / objdump.exp
CommitLineData
8c2bc687
NC
1# Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
2# Free Software Foundation, Inc.
252b5132
RH
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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18# Please email any bugs, comments, and/or additions to this file to:
19# bug-dejagnu@prep.ai.mit.edu
20
21# This file was written by Rob Savoye <rob@cygnus.com>
22# and rewritten by Ian Lance Taylor <ian@cygnus.com>
23
24if ![is_remote host] {
25 if {[which $OBJDUMP] == 0} then {
26 perror "$OBJDUMP does not exist"
27 return
28 }
29}
30
31send_user "Version [binutil_version $OBJDUMP]"
32
33# Simple test of objdump -i
34
35set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -i"]
36
41f5a528
FCE
37set cpus_expected [list]
38lappend cpus_expected a29k alliant alpha arc arm convex
7c3f9ad0 39lappend cpus_expected d10v d30v fr30 fr500 fr550 h8 hppa i386 i860 i960 ip2022
41f5a528 40lappend cpus_expected m32r m68hc11 m68hc12 m68k m88k MCore
a46a5b58 41lappend cpus_expected mips mn10200 mn10300 msp ns32k pj powerpc pyramid
8de397a5 42lappend cpus_expected romp rs6000 s390 sh sparc
026df7c5 43lappend cpus_expected tahoe tic54x tic80 tms320c30 tms320c4x tms320c54x v850
4a69ea0b 44lappend cpus_expected vax we32k x86-64 xscale z8k z8001 z8002
252b5132
RH
45
46# Make sure the target CPU shows up in the list.
41f5a528
FCE
47lappend cpus_expected ${target_cpu}
48
49# Create regexp
50set cpus_regex "([join $cpus_expected | ])"
51
52verbose -log "CPU regex: $cpus_regex"
252b5132 53
41f5a528 54set want "BFD header file version.*srec\[^\n\]*\n\[^\n\]*header \[^\n\]*endian\[^\n\]*, data \[^\n\]*endian.*$cpus_regex"
252b5132
RH
55
56if [regexp $want $got] then {
57 pass "objdump -i"
58} else {
59 fail "objdump -i"
60}
61
62# The remaining tests require a test file.
63
64
65if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
66 return
67}
68if [is_remote host] {
69 set testfile [remote_download host tmpdir/bintest.o]
70} else {
71 set testfile tmpdir/bintest.o
72}
73
74# Test objdump -f
75
76set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f $testfile"]
77
41f5a528 78set want "$testfile:\[ \]*file format.*architecture:\[ \]*${cpus_regex}.*HAS_RELOC.*HAS_SYMS"
252b5132
RH
79
80if ![regexp $want $got] then {
81 fail "objdump -f"
82} else {
83 pass "objdump -f"
84}
85
86# Test objdump -h
87
88set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h $testfile"]
89
90set want "$testfile:\[ \]*file format.*Sections.*\[0-9\]+\[ \]+\[^ \]*(text|TEXT|\\\$CODE\\\$)\[^ \]*\[ \]*(\[0-9a-fA-F\]+).*\[0-9\]+\[ \]+\[^ \]*(\\.data|DATA)\[^ \]*\[ \]*(\[0-9a-fA-F\]+)"
91
92if ![regexp $want $got all text_name text_size data_name data_size] then {
93 fail "objdump -h"
94} else {
95 verbose "text name is $text_name size is $text_size"
96 verbose "data name is $data_name size is $data_size"
60bcf0fa
NC
97 set ets 8
98 set eds 4
48c5eb8a
SS
99 # The [ti]c4x target has the property sizeof(char)=sizeof(long)=1
100 if [istarget *c4x*-*-*] then {
101 set ets 2
102 set eds 1
103 }
60bcf0fa
NC
104 # c54x section sizes are in bytes, not octets; adjust accordingly
105 if [istarget *c54x*-*-*] then {
106 set ets 4
107 set eds 2
108 }
109 if {[expr "0x$text_size"] < $ets || [expr "0x$data_size"] < $eds} then {
252b5132
RH
110 send_log "sizes too small\n"
111 fail "objdump -h"
112 } else {
113 pass "objdump -h"
114 }
115}
116
117# Test objdump -t
118
119set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -t $testfile"]
120
121if [info exists vars] then { unset vars }
122while {[regexp "(\[a-z\]*_symbol)(.*)" $got all symbol rest]} {
123 set vars($symbol) 1
124 set got $rest
125}
126
127if {![info exists vars(text_symbol)] \
128 || ![info exists vars(data_symbol)] \
129 || ![info exists vars(common_symbol)] \
130 || ![info exists vars(external_symbol)]} then {
131 fail "objdump -t"
132} else {
133 pass "objdump -t"
134}
135
136# Test objdump -r
137
138set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $testfile"]
139
140set want "$testfile:\[ \]*file format.*RELOCATION RECORDS FOR \\\[\[^\]\]*(text|TEXT|\\\$CODE\\\$)\[^\]\]*\\\].*external_symbol"
141
142if [regexp $want $got] then {
143 pass "objdump -r"
144} else {
145 fail "objdump -r"
146}
147
148# Test objdump -s
149
150set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s $testfile"]
151
60bcf0fa 152set 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
153
154if [regexp $want $got] then {
155 pass "objdump -s"
156} else {
157 fail "objdump -s"
158}
159
160# Options which are not tested: -a -d -D -R -T -x -l --stabs
161# I don't see any generic way to test any of these other than -a.
162# Tests could be written for specific targets, and that should be done
163# if specific problems are found.
This page took 0.195789 seconds and 4 git commands to generate.