Applied Stephane Carrez <Stephane.Carrez@worldnet.fr> patches to add support
[deliverable/binutils-gdb.git] / binutils / testsuite / binutils-all / objdump.exp
CommitLineData
252b5132
RH
1# Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
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
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
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.
12#
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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
60bcf0fa 36set cpus_expected "(a29k|alliant|alpha|arc|arm|convex|d10v|d30v|fr30|h8|hppa|i386|i860|i960|m32r|m68hc11|m68hc12|m68k|m88k|MCore|mips|mn10200|mn10300|ns32k|pj|powerpc|pyramid|romp|rs6000|sh|sparc|tahoe|v850|vax|we32k|z8k|z8001|z8002)"
252b5132
RH
37
38# Make sure the target CPU shows up in the list.
39if ![regexp $cpus_expected $target_cpu] {
40 regsub "^\[(\]" "$cpus_expected" "(${target_cpu}|" cpus_expected;
41}
42
30264433 43set want "BFD header file version.*srec\[^\n\]*\n\[^\n\]*header \[^\n\]*endian\[^\n\]*, data \[^\n\]*endian.*$cpus_expected"
252b5132
RH
44
45if [regexp $want $got] then {
46 pass "objdump -i"
47} else {
48 fail "objdump -i"
49}
50
51# The remaining tests require a test file.
52
53
54if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
55 return
56}
57if [is_remote host] {
58 set testfile [remote_download host tmpdir/bintest.o]
59} else {
60 set testfile tmpdir/bintest.o
61}
62
63# Test objdump -f
64
65set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f $testfile"]
66
67set want "$testfile:\[ \]*file format.*architecture:\[ \]*${cpus_expected}.*HAS_RELOC.*HAS_SYMS"
68
69if ![regexp $want $got] then {
70 fail "objdump -f"
71} else {
72 pass "objdump -f"
73}
74
75# Test objdump -h
76
77set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h $testfile"]
78
79set want "$testfile:\[ \]*file format.*Sections.*\[0-9\]+\[ \]+\[^ \]*(text|TEXT|\\\$CODE\\\$)\[^ \]*\[ \]*(\[0-9a-fA-F\]+).*\[0-9\]+\[ \]+\[^ \]*(\\.data|DATA)\[^ \]*\[ \]*(\[0-9a-fA-F\]+)"
80
81if ![regexp $want $got all text_name text_size data_name data_size] then {
82 fail "objdump -h"
83} else {
84 verbose "text name is $text_name size is $text_size"
85 verbose "data name is $data_name size is $data_size"
60bcf0fa
NC
86 set ets 8
87 set eds 4
88 # c54x section sizes are in bytes, not octets; adjust accordingly
89 if [istarget *c54x*-*-*] then {
90 set ets 4
91 set eds 2
92 }
93 if {[expr "0x$text_size"] < $ets || [expr "0x$data_size"] < $eds} then {
252b5132
RH
94 send_log "sizes too small\n"
95 fail "objdump -h"
96 } else {
97 pass "objdump -h"
98 }
99}
100
101# Test objdump -t
102
103set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -t $testfile"]
104
105if [info exists vars] then { unset vars }
106while {[regexp "(\[a-z\]*_symbol)(.*)" $got all symbol rest]} {
107 set vars($symbol) 1
108 set got $rest
109}
110
111if {![info exists vars(text_symbol)] \
112 || ![info exists vars(data_symbol)] \
113 || ![info exists vars(common_symbol)] \
114 || ![info exists vars(external_symbol)]} then {
115 fail "objdump -t"
116} else {
117 pass "objdump -t"
118}
119
120# Test objdump -r
121
122set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $testfile"]
123
124set want "$testfile:\[ \]*file format.*RELOCATION RECORDS FOR \\\[\[^\]\]*(text|TEXT|\\\$CODE\\\$)\[^\]\]*\\\].*external_symbol"
125
126if [regexp $want $got] then {
127 pass "objdump -r"
128} else {
129 fail "objdump -r"
130}
131
132# Test objdump -s
133
134set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s $testfile"]
135
60bcf0fa 136set 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
137
138if [regexp $want $got] then {
139 pass "objdump -s"
140} else {
141 fail "objdump -s"
142}
143
144# Options which are not tested: -a -d -D -R -T -x -l --stabs
145# I don't see any generic way to test any of these other than -a.
146# Tests could be written for specific targets, and that should be done
147# if specific problems are found.
This page took 0.050428 seconds and 4 git commands to generate.