| 1 |
15 |
khays |
# Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
| 2 |
|
|
# 2003, 2004, 2007, 2008, 2009
|
| 3 |
|
|
# Free Software Foundation, Inc.
|
| 4 |
|
|
|
| 5 |
|
|
# This program is free software; you can redistribute it and/or modify
|
| 6 |
|
|
# it under the terms of the GNU General Public License as published by
|
| 7 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
| 8 |
|
|
# (at your option) any later version.
|
| 9 |
|
|
#
|
| 10 |
|
|
# This program is distributed in the hope that it will be useful,
|
| 11 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 |
|
|
# GNU General Public License for more details.
|
| 14 |
|
|
#
|
| 15 |
|
|
# You should have received a copy of the GNU General Public License
|
| 16 |
|
|
# along with this program; if not, write to the Free Software
|
| 17 |
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
| 18 |
|
|
|
| 19 |
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
| 20 |
|
|
# bug-dejagnu@prep.ai.mit.edu
|
| 21 |
|
|
|
| 22 |
|
|
# This file was written by Rob Savoye
|
| 23 |
|
|
# and rewritten by Ian Lance Taylor
|
| 24 |
|
|
|
| 25 |
|
|
if ![is_remote host] {
|
| 26 |
|
|
if {[which $OBJDUMP] == 0} then {
|
| 27 |
|
|
perror "$OBJDUMP does not exist"
|
| 28 |
|
|
return
|
| 29 |
|
|
}
|
| 30 |
|
|
}
|
| 31 |
|
|
|
| 32 |
|
|
send_user "Version [binutil_version $OBJDUMP]"
|
| 33 |
|
|
|
| 34 |
|
|
# Simple test of objdump -i
|
| 35 |
|
|
|
| 36 |
|
|
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -i"]
|
| 37 |
|
|
|
| 38 |
|
|
set cpus_expected [list]
|
| 39 |
|
|
lappend cpus_expected alpha arc arm cris
|
| 40 |
|
|
lappend cpus_expected d10v d30v fr30 fr500 fr550 h8 hppa i386 i860 i960 ip2022
|
| 41 |
|
|
lappend cpus_expected m16c m32c m32r m68hc11 m68hc12 m68k m88k MCore
|
| 42 |
|
|
lappend cpus_expected mips mn10200 mn10300 ms1 msp ns32k pj powerpc pyramid
|
| 43 |
|
|
lappend cpus_expected romp rs6000 s390 sh sparc
|
| 44 |
|
|
lappend cpus_expected tahoe tic54x tic80 tms320c30 tms320c4x tms320c54x v850
|
| 45 |
|
|
lappend cpus_expected vax we32k x86-64 xscale xtensa z8k z8001 z8002
|
| 46 |
|
|
lappend cpus_expected open8
|
| 47 |
|
|
|
| 48 |
|
|
# Make sure the target CPU shows up in the list.
|
| 49 |
|
|
lappend cpus_expected ${target_cpu}
|
| 50 |
|
|
|
| 51 |
|
|
# Create regexp
|
| 52 |
|
|
set cpus_regex "([join $cpus_expected | ])"
|
| 53 |
|
|
|
| 54 |
|
|
verbose -log "CPU regex: $cpus_regex"
|
| 55 |
|
|
|
| 56 |
|
|
set want "BFD header file version.*srec\[^\n\]*\n\[^\n\]*header \[^\n\]*endian\[^\n\]*, data \[^\n\]*endian.*$cpus_regex"
|
| 57 |
|
|
|
| 58 |
|
|
if [regexp $want $got] then {
|
| 59 |
|
|
pass "objdump -i"
|
| 60 |
|
|
} else {
|
| 61 |
|
|
fail "objdump -i"
|
| 62 |
|
|
}
|
| 63 |
|
|
|
| 64 |
|
|
# The remaining tests require a test file.
|
| 65 |
|
|
|
| 66 |
|
|
|
| 67 |
|
|
if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
|
| 68 |
|
|
return
|
| 69 |
|
|
}
|
| 70 |
|
|
if [is_remote host] {
|
| 71 |
|
|
set testfile [remote_download host tmpdir/bintest.o]
|
| 72 |
|
|
} else {
|
| 73 |
|
|
set testfile tmpdir/bintest.o
|
| 74 |
|
|
}
|
| 75 |
|
|
|
| 76 |
|
|
# Test objdump -f
|
| 77 |
|
|
|
| 78 |
|
|
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f $testfile"]
|
| 79 |
|
|
|
| 80 |
|
|
set want "$testfile:\[ \]*file format.*architecture:\[ \]*${cpus_regex}.*HAS_RELOC.*HAS_SYMS"
|
| 81 |
|
|
|
| 82 |
|
|
if ![regexp $want $got] then {
|
| 83 |
|
|
fail "objdump -f"
|
| 84 |
|
|
} else {
|
| 85 |
|
|
pass "objdump -f"
|
| 86 |
|
|
}
|
| 87 |
|
|
|
| 88 |
|
|
# Test objdump -h
|
| 89 |
|
|
|
| 90 |
|
|
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h $testfile"]
|
| 91 |
|
|
|
| 92 |
|
|
set want "$testfile:\[ \]*file format.*Sections.*\[0-9\]+\[ \]+\[^ \]*(text|TEXT|\\\$CODE\\\$)\[^ \]*\[ \]*(\[0-9a-fA-F\]+).*\[0-9\]+\[ \]+\[^ \]*(\\.data|DATA)\[^ \]*\[ \]*(\[0-9a-fA-F\]+)"
|
| 93 |
|
|
|
| 94 |
|
|
if ![regexp $want $got all text_name text_size data_name data_size] then {
|
| 95 |
|
|
fail "objdump -h"
|
| 96 |
|
|
} else {
|
| 97 |
|
|
verbose "text name is $text_name size is $text_size"
|
| 98 |
|
|
verbose "data name is $data_name size is $data_size"
|
| 99 |
|
|
set ets 8
|
| 100 |
|
|
set eds 4
|
| 101 |
|
|
# The [ti]c4x target has the property sizeof(char)=sizeof(long)=1
|
| 102 |
|
|
if [istarget *c4x*-*-*] then {
|
| 103 |
|
|
set ets 2
|
| 104 |
|
|
set eds 1
|
| 105 |
|
|
}
|
| 106 |
|
|
# c54x section sizes are in bytes, not octets; adjust accordingly
|
| 107 |
|
|
if [istarget *c54x*-*-*] then {
|
| 108 |
|
|
set ets 4
|
| 109 |
|
|
set eds 2
|
| 110 |
|
|
}
|
| 111 |
|
|
if {[expr "0x$text_size"] < $ets || [expr "0x$data_size"] < $eds} then {
|
| 112 |
|
|
send_log "sizes too small\n"
|
| 113 |
|
|
fail "objdump -h"
|
| 114 |
|
|
} else {
|
| 115 |
|
|
pass "objdump -h"
|
| 116 |
|
|
}
|
| 117 |
|
|
}
|
| 118 |
|
|
|
| 119 |
|
|
# Test objdump -t
|
| 120 |
|
|
|
| 121 |
|
|
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -t $testfile"]
|
| 122 |
|
|
|
| 123 |
|
|
if [info exists vars] then { unset vars }
|
| 124 |
|
|
while {[regexp "(\[a-z\]*_symbol)(.*)" $got all symbol rest]} {
|
| 125 |
|
|
set vars($symbol) 1
|
| 126 |
|
|
set got $rest
|
| 127 |
|
|
}
|
| 128 |
|
|
|
| 129 |
|
|
if {![info exists vars(text_symbol)] \
|
| 130 |
|
|
|| ![info exists vars(data_symbol)] \
|
| 131 |
|
|
|| ![info exists vars(common_symbol)] \
|
| 132 |
|
|
|| ![info exists vars(external_symbol)]} then {
|
| 133 |
|
|
fail "objdump -t"
|
| 134 |
|
|
} else {
|
| 135 |
|
|
pass "objdump -t"
|
| 136 |
|
|
}
|
| 137 |
|
|
|
| 138 |
|
|
# Test objdump -r
|
| 139 |
|
|
|
| 140 |
|
|
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $testfile"]
|
| 141 |
|
|
|
| 142 |
|
|
set want "$testfile:\[ \]*file format.*RELOCATION RECORDS FOR \\\[\[^\]\]*(text|TEXT|\\\$CODE\\\$)\[^\]\]*\\\].*external_symbol"
|
| 143 |
|
|
|
| 144 |
|
|
if [regexp $want $got] then {
|
| 145 |
|
|
pass "objdump -r"
|
| 146 |
|
|
} else {
|
| 147 |
|
|
fail "objdump -r"
|
| 148 |
|
|
}
|
| 149 |
|
|
|
| 150 |
|
|
# Test objdump -s
|
| 151 |
|
|
|
| 152 |
|
|
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s $testfile"]
|
| 153 |
|
|
|
| 154 |
|
|
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)"
|
| 155 |
|
|
|
| 156 |
|
|
if [regexp $want $got] then {
|
| 157 |
|
|
pass "objdump -s"
|
| 158 |
|
|
} else {
|
| 159 |
|
|
fail "objdump -s"
|
| 160 |
|
|
}
|
| 161 |
|
|
|
| 162 |
|
|
# Test objdump -s on a file that contains a compressed .debug section
|
| 163 |
|
|
|
| 164 |
|
|
if { ![is_elf_format] } then {
|
| 165 |
|
|
unsupported "objdump compressed debug"
|
| 166 |
|
|
} elseif { ![binutils_assemble $srcdir/$subdir/dw2-compressed.S tmpdir/dw2-compressed.o] } then {
|
| 167 |
|
|
fail "objdump compressed debug"
|
| 168 |
|
|
} else {
|
| 169 |
|
|
if [is_remote host] {
|
| 170 |
|
|
set compressed_testfile [remote_download host tmpdir/dw2-compressed.o]
|
| 171 |
|
|
} else {
|
| 172 |
|
|
set compressed_testfile tmpdir/dw2-compressed.o
|
| 173 |
|
|
}
|
| 174 |
|
|
|
| 175 |
|
|
set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -s -j .zdebug_abbrev $compressed_testfile" "" "/dev/null" "objdump.out"]
|
| 176 |
|
|
|
| 177 |
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
| 178 |
|
|
fail "objdump -s -j .zdebug_abbrev (reason: unexpected output)"
|
| 179 |
|
|
send_log $got
|
| 180 |
|
|
send_log "\n"
|
| 181 |
|
|
}
|
| 182 |
|
|
|
| 183 |
|
|
if { [regexp_diff objdump.out $srcdir/$subdir/objdump.s] } then {
|
| 184 |
|
|
fail "objdump -s -j .zdebug_abbrev"
|
| 185 |
|
|
} else {
|
| 186 |
|
|
pass "objdump -s -j .zdebug_abbrev"
|
| 187 |
|
|
}
|
| 188 |
|
|
|
| 189 |
|
|
# Test objdump -W on a file that contains some compressed .debug sections
|
| 190 |
|
|
|
| 191 |
|
|
set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -W $compressed_testfile" "" "/dev/null" "objdump.out"]
|
| 192 |
|
|
|
| 193 |
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
| 194 |
|
|
fail "objdump -W (reason: unexpected output)"
|
| 195 |
|
|
send_log $got
|
| 196 |
|
|
send_log "\n"
|
| 197 |
|
|
}
|
| 198 |
|
|
|
| 199 |
|
|
if { [regexp_diff objdump.out $srcdir/$subdir/objdump.W] } then {
|
| 200 |
|
|
fail "objdump -W"
|
| 201 |
|
|
} else {
|
| 202 |
|
|
pass "objdump -W"
|
| 203 |
|
|
}
|
| 204 |
|
|
}
|
| 205 |
|
|
|
| 206 |
|
|
|
| 207 |
|
|
# Options which are not tested: -a -d -D -R -T -x -l --stabs
|
| 208 |
|
|
# I don't see any generic way to test any of these other than -a.
|
| 209 |
|
|
# Tests could be written for specific targets, and that should be done
|
| 210 |
|
|
# if specific problems are found.
|