Commit | Line | Data |
---|---|---|
41f5a528 | 1 | # Copyright (C) 1993, 1994, 1995, 1996, 2000 Free Software Foundation, Inc. |
252b5132 RH |
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 | ||
23 | if ![is_remote host] { | |
24 | if {[which $OBJDUMP] == 0} then { | |
25 | perror "$OBJDUMP does not exist" | |
26 | return | |
27 | } | |
28 | } | |
29 | ||
30 | send_user "Version [binutil_version $OBJDUMP]" | |
31 | ||
32 | # Simple test of objdump -i | |
33 | ||
34 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -i"] | |
35 | ||
41f5a528 FCE |
36 | set cpus_expected [list] |
37 | lappend cpus_expected a29k alliant alpha arc arm convex | |
38 | lappend cpus_expected d10v d30v fr30 h8 hppa i386 i860 i960 | |
39 | lappend cpus_expected m32r m68hc11 m68hc12 m68k m88k MCore | |
40 | lappend cpus_expected mips mn10200 mn10300 ns32k pj powerpc pyramid | |
41 | lappend cpus_expected romp rs6000 sh sparc tahoe v850 | |
42 | lappend cpus_expected vax we32k z8k z8001 z8002 | |
252b5132 RH |
43 | |
44 | # Make sure the target CPU shows up in the list. | |
41f5a528 FCE |
45 | lappend cpus_expected ${target_cpu} |
46 | ||
47 | # Create regexp | |
48 | set cpus_regex "([join $cpus_expected | ])" | |
49 | ||
50 | verbose -log "CPU regex: $cpus_regex" | |
252b5132 | 51 | |
41f5a528 | 52 | set want "BFD header file version.*srec\[^\n\]*\n\[^\n\]*header \[^\n\]*endian\[^\n\]*, data \[^\n\]*endian.*$cpus_regex" |
252b5132 RH |
53 | |
54 | if [regexp $want $got] then { | |
55 | pass "objdump -i" | |
56 | } else { | |
57 | fail "objdump -i" | |
58 | } | |
59 | ||
60 | # The remaining tests require a test file. | |
61 | ||
62 | ||
63 | if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then { | |
64 | return | |
65 | } | |
66 | if [is_remote host] { | |
67 | set testfile [remote_download host tmpdir/bintest.o] | |
68 | } else { | |
69 | set testfile tmpdir/bintest.o | |
70 | } | |
71 | ||
72 | # Test objdump -f | |
73 | ||
74 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f $testfile"] | |
75 | ||
41f5a528 | 76 | set want "$testfile:\[ \]*file format.*architecture:\[ \]*${cpus_regex}.*HAS_RELOC.*HAS_SYMS" |
252b5132 RH |
77 | |
78 | if ![regexp $want $got] then { | |
79 | fail "objdump -f" | |
80 | } else { | |
81 | pass "objdump -f" | |
82 | } | |
83 | ||
84 | # Test objdump -h | |
85 | ||
86 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h $testfile"] | |
87 | ||
88 | set want "$testfile:\[ \]*file format.*Sections.*\[0-9\]+\[ \]+\[^ \]*(text|TEXT|\\\$CODE\\\$)\[^ \]*\[ \]*(\[0-9a-fA-F\]+).*\[0-9\]+\[ \]+\[^ \]*(\\.data|DATA)\[^ \]*\[ \]*(\[0-9a-fA-F\]+)" | |
89 | ||
90 | if ![regexp $want $got all text_name text_size data_name data_size] then { | |
91 | fail "objdump -h" | |
92 | } else { | |
93 | verbose "text name is $text_name size is $text_size" | |
94 | verbose "data name is $data_name size is $data_size" | |
60bcf0fa NC |
95 | set ets 8 |
96 | set eds 4 | |
97 | # c54x section sizes are in bytes, not octets; adjust accordingly | |
98 | if [istarget *c54x*-*-*] then { | |
99 | set ets 4 | |
100 | set eds 2 | |
101 | } | |
102 | if {[expr "0x$text_size"] < $ets || [expr "0x$data_size"] < $eds} then { | |
252b5132 RH |
103 | send_log "sizes too small\n" |
104 | fail "objdump -h" | |
105 | } else { | |
106 | pass "objdump -h" | |
107 | } | |
108 | } | |
109 | ||
110 | # Test objdump -t | |
111 | ||
112 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -t $testfile"] | |
113 | ||
114 | if [info exists vars] then { unset vars } | |
115 | while {[regexp "(\[a-z\]*_symbol)(.*)" $got all symbol rest]} { | |
116 | set vars($symbol) 1 | |
117 | set got $rest | |
118 | } | |
119 | ||
120 | if {![info exists vars(text_symbol)] \ | |
121 | || ![info exists vars(data_symbol)] \ | |
122 | || ![info exists vars(common_symbol)] \ | |
123 | || ![info exists vars(external_symbol)]} then { | |
124 | fail "objdump -t" | |
125 | } else { | |
126 | pass "objdump -t" | |
127 | } | |
128 | ||
129 | # Test objdump -r | |
130 | ||
131 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $testfile"] | |
132 | ||
133 | set want "$testfile:\[ \]*file format.*RELOCATION RECORDS FOR \\\[\[^\]\]*(text|TEXT|\\\$CODE\\\$)\[^\]\]*\\\].*external_symbol" | |
134 | ||
135 | if [regexp $want $got] then { | |
136 | pass "objdump -r" | |
137 | } else { | |
138 | fail "objdump -r" | |
139 | } | |
140 | ||
141 | # Test objdump -s | |
142 | ||
143 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s $testfile"] | |
144 | ||
60bcf0fa | 145 | 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)" |
252b5132 RH |
146 | |
147 | if [regexp $want $got] then { | |
148 | pass "objdump -s" | |
149 | } else { | |
150 | fail "objdump -s" | |
151 | } | |
152 | ||
153 | # Options which are not tested: -a -d -D -R -T -x -l --stabs | |
154 | # I don't see any generic way to test any of these other than -a. | |
155 | # Tests could be written for specific targets, and that should be done | |
156 | # if specific problems are found. |