Fix typos in ChangeLogs and update copyright notices
[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
39lappend cpus_expected d10v d30v fr30 h8 hppa i386 i860 i960
40lappend cpus_expected m32r m68hc11 m68hc12 m68k m88k MCore
41lappend cpus_expected mips mn10200 mn10300 ns32k pj powerpc pyramid
968fa2cc 42lappend cpus_expected romp rs6000 sh sparc tahoe tic54x tms320c54x v850
41f5a528 43lappend cpus_expected vax we32k 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
98 # c54x section sizes are in bytes, not octets; adjust accordingly
99 if [istarget *c54x*-*-*] then {
100 set ets 4
101 set eds 2
102 }
103 if {[expr "0x$text_size"] < $ets || [expr "0x$data_size"] < $eds} then {
252b5132
RH
104 send_log "sizes too small\n"
105 fail "objdump -h"
106 } else {
107 pass "objdump -h"
108 }
109}
110
111# Test objdump -t
112
113set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -t $testfile"]
114
115if [info exists vars] then { unset vars }
116while {[regexp "(\[a-z\]*_symbol)(.*)" $got all symbol rest]} {
117 set vars($symbol) 1
118 set got $rest
119}
120
121if {![info exists vars(text_symbol)] \
122 || ![info exists vars(data_symbol)] \
123 || ![info exists vars(common_symbol)] \
124 || ![info exists vars(external_symbol)]} then {
125 fail "objdump -t"
126} else {
127 pass "objdump -t"
128}
129
130# Test objdump -r
131
132set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $testfile"]
133
134set want "$testfile:\[ \]*file format.*RELOCATION RECORDS FOR \\\[\[^\]\]*(text|TEXT|\\\$CODE\\\$)\[^\]\]*\\\].*external_symbol"
135
136if [regexp $want $got] then {
137 pass "objdump -r"
138} else {
139 fail "objdump -r"
140}
141
142# Test objdump -s
143
144set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s $testfile"]
145
60bcf0fa 146set 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
147
148if [regexp $want $got] then {
149 pass "objdump -s"
150} else {
151 fail "objdump -s"
152}
153
154# Options which are not tested: -a -d -D -R -T -x -l --stabs
155# I don't see any generic way to test any of these other than -a.
156# Tests could be written for specific targets, and that should be done
157# if specific problems are found.
This page took 0.074862 seconds and 4 git commands to generate.