2015-01-01 14:15:26 +00:00
|
|
|
# Copyright (C) 1999-2015 Free Software Foundation, Inc.
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-07-05 16:54:46 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
1999-05-03 07:29:11 +00:00
|
|
|
# (at your option) any later version.
|
2012-11-27 17:26:11 +00:00
|
|
|
#
|
1999-05-03 07:29:11 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2012-11-27 17:26:11 +00:00
|
|
|
#
|
1999-05-03 07:29:11 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2005-05-08 14:17:41 +00:00
|
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
|
|
|
# bug-dejagnu@prep.ai.mit.edu
|
|
|
|
|
2000-05-02 12:47:19 +00:00
|
|
|
# Written by Nick Clifton <nickc@cygnus.com>
|
1999-05-03 07:29:11 +00:00
|
|
|
# Based on scripts written by Ian Lance Taylor <ian@cygnus.com>
|
|
|
|
# and Ken Raeburn <raeburn@cygnus.com>.
|
|
|
|
|
2007-08-30 13:47:35 +00:00
|
|
|
# Exclude non-ELF targets.
|
|
|
|
if ![is_elf_format] {
|
|
|
|
verbose "$READELF is only intended for ELF targets" 2
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
# First some helpful procedures, then the tests themselves
|
|
|
|
|
|
|
|
# Return the contents of the filename given
|
|
|
|
proc file_contents { filename } {
|
|
|
|
set file [open $filename r]
|
|
|
|
set contents [read $file]
|
|
|
|
close $file
|
|
|
|
return $contents
|
|
|
|
}
|
|
|
|
|
2000-06-14 01:21:35 +00:00
|
|
|
# Find out the size by reading the output of the EI_CLASS field.
|
|
|
|
# Similar to the test for readelf -h, but we're just looking for the
|
|
|
|
# EI_CLASS line here.
|
|
|
|
proc readelf_find_size { binary_file } {
|
|
|
|
global READELF
|
|
|
|
global READELFFLAGS
|
|
|
|
global readelf_size
|
|
|
|
|
|
|
|
set readelf_size ""
|
|
|
|
set testname "finding out ELF size with readelf -h"
|
2007-08-28 13:21:58 +00:00
|
|
|
set got [remote_exec host "$READELF $READELFFLAGS -h $binary_file" "" "/dev/null" "readelf.out"]
|
|
|
|
if [is_remote host] then {
|
|
|
|
remote_upload host "readelf.out"
|
|
|
|
}
|
2000-06-14 01:21:35 +00:00
|
|
|
|
2007-08-28 13:21:58 +00:00
|
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]]} then {
|
2000-06-14 01:21:35 +00:00
|
|
|
send_log $got
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if { ! [regexp "\n\[ \]*Class:\[ \]*ELF(\[0-9\]+)\n" \
|
|
|
|
[file_contents readelf.out] nil readelf_size] } {
|
|
|
|
verbose -log "EI_CLASS field not found in output"
|
|
|
|
verbose -log "output is \n[file_contents readelf.out]"
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
} else {
|
|
|
|
verbose -log "ELF size is $readelf_size"
|
|
|
|
}
|
|
|
|
|
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
# Run an individual readelf test.
|
|
|
|
# Basically readelf is run on the binary_file with the given options.
|
|
|
|
# Readelf's output is captured and then compared against the contents
|
2000-06-14 01:21:35 +00:00
|
|
|
# of the regexp_file-readelf_size if it exists, else regexp_file.
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
proc readelf_test { options binary_file regexp_file xfails } {
|
|
|
|
|
|
|
|
global READELF
|
|
|
|
global READELFFLAGS
|
2000-06-14 01:21:35 +00:00
|
|
|
global readelf_size
|
1999-05-03 07:29:11 +00:00
|
|
|
global srcdir
|
|
|
|
global subdir
|
2012-11-27 17:26:11 +00:00
|
|
|
|
2000-06-14 01:21:35 +00:00
|
|
|
send_log "exec $READELF $READELFFLAGS $options $binary_file > readelf.out\n"
|
2007-08-28 13:21:58 +00:00
|
|
|
set got [remote_exec host "$READELF $READELFFLAGS $options $binary_file" "" "/dev/null" "readelf.out"]
|
1999-05-03 07:29:11 +00:00
|
|
|
|
2000-10-19 18:04:56 +00:00
|
|
|
foreach xfail $xfails {
|
|
|
|
setup_xfail $xfail
|
1999-05-03 07:29:11 +00:00
|
|
|
}
|
2003-04-23 17:36:08 +00:00
|
|
|
|
2007-08-28 13:21:58 +00:00
|
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
2003-04-23 17:36:08 +00:00
|
|
|
fail "readelf $options (reason: unexpected output)"
|
1999-05-03 07:29:11 +00:00
|
|
|
send_log $got
|
2003-04-23 17:36:08 +00:00
|
|
|
send_log "\n"
|
1999-05-03 07:29:11 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2000-11-03 01:59:12 +00:00
|
|
|
set target_machine ""
|
|
|
|
if [istarget "mips*-*-*"] then {
|
bfd/
2010-12-23 Robert Millan <rmh@gnu.org>
* config.bfd: Recognize mips-freebsd and mips-kfreebsd-gnu.
* configure.host: Likewise.
* configure.in: Support for `bfd_elf32_ntradbigmips_freebsd_vec',
`bfd_elf32_ntradlittlemips_freebsd_vec',
`bfd_elf32_tradbigmips_freebsd_vec',
`bfd_elf32_tradlittlemips_freebsd_vec',
`bfd_elf64_tradbigmips_freebsd_vec' and
`bfd_elf64_tradlittlemips_freebsd_vec'.
* configure: Regenerate.
* elf32-mips.c: New target for FreeBSD support
(same as traditional MIPS but overrides ELF_OSABI
with ELFOSABI_FREEBSD).
* elf64-mips.c: Likewise.
* elfn32-mips.c: Likewise.
* targets.c (_bfd_target_vector): Add
`bfd_elf32_ntradbigmips_freebsd_vec',
`bfd_elf32_ntradlittlemips_freebsd_vec',
`bfd_elf32_tradbigmips_freebsd_vec',
`bfd_elf32_tradlittlemips_freebsd_vec',
`bfd_elf64_tradbigmips_freebsd_vec' and
`bfd_elf64_tradlittlemips_freebsd_vec'.
ld/
2010-12-14 Robert Millan <rmh@gnu.org>
* configure.tgt: Recognize mips-freebsd and mips-kfreebsd-gnu.
* emulparams/elf32btsmip_fbsd.sh: New file.
* emulparams/elf32btsmipn32_fbsd.sh: Likewise.
* emulparams/elf32ltsmip_fbsd.sh: Likewise.
* emulparams/elf32ltsmipn32_fbsd.sh: Likewise.
* emulparams/elf64btsmip_fbsd.sh: Likewise.
* emulparams/elf64ltsmip_fbsd.sh: Likewise.
* Makefile.am: Add build rules for `eelf32btsmip_fbsd.c',
`eelf32btsmipn32_fbsd.c', `eelf32ltsmip_fbsd.c',
`eelf32ltsmipn32_fbsd.c', `eelf64btsmip_fbsd.c' and
`eelf64ltsmip_fbsd.c'.
* Makefile.in: Regenerate.
gas/
2010-12-19 Robert Millan <rmh@gnu.org>
Richard Sandiford <rdsandiford@googlemail.com>
* config/tc-mips.c (ELF_TARGET): New macro. Generates target
names accordingly to whether TE_FreeBSD and whether TE_TMIPS
are defined.
(mips_target_format): Refactor code using ELF_TARGET().
(support_64bit_objects): Likewise.
* configure.in: Recognize mips-freebsd and mips-kfreebsd-gnu.
* configure.tgt: Likewise.
* configure: Regenerate.
binutils/testsuite/
* binutils-all/readelf.exp: Handle MIPS FreeBSD targets.
gas/testsuite/
* gas/mips/e32el-rel2.d: Accept any file format.
* gas/mips/elf-rel.d: Likewise.
* gas/mips/elf-rel2.d: Likewise.
* gas/mips/elf-rel3.d: Likewise.
* gas/mips/elfel-rel.d: Likewise.
* gas/mips/elfel-rel2.d: Likewise.
* gas/mips/elfel-rel3.d: Likewise.
* gas/mips/ldstla-32-mips3-shared.d: Likewise.
* gas/mips/ldstla-32-mips3.d: Likewise.
* gas/mips/ldstla-32-shared.d: Likewise.
* gas/mips/ldstla-32.d: Likewise.
* gas/mips/ldstla-n64-shared.d: Likewise.
* gas/mips/ldstla-n64.d: Likewise.
* gas/mips/noat-1.d: Likewise.
* gas/mips/set-arch.d: Likewise.
* gas/mips/tls-o32.d: Likewise.
ld/testsuite/
* ld-mips-elf/mips-elf-flags.exp: Handle FreeBSD targets.
* ld-mips-elf/mips-elf.exp: Likewise.
* ld-mips-elf/mips16-call-global.d: Accept any file format.
* ld-mips-elf/mips16-intermix.d: Likewise.
2010-12-31 11:01:00 +00:00
|
|
|
if { [istarget "mips*-*-*linux*"]
|
|
|
|
|| [istarget "mips*-sde-elf*"]
|
2013-11-27 09:11:06 +00:00
|
|
|
|| [istarget "mips*-mti-elf*"]
|
2014-09-10 11:41:28 +00:00
|
|
|
|| [istarget "mips*-img-elf*"]
|
bfd/
2010-12-23 Robert Millan <rmh@gnu.org>
* config.bfd: Recognize mips-freebsd and mips-kfreebsd-gnu.
* configure.host: Likewise.
* configure.in: Support for `bfd_elf32_ntradbigmips_freebsd_vec',
`bfd_elf32_ntradlittlemips_freebsd_vec',
`bfd_elf32_tradbigmips_freebsd_vec',
`bfd_elf32_tradlittlemips_freebsd_vec',
`bfd_elf64_tradbigmips_freebsd_vec' and
`bfd_elf64_tradlittlemips_freebsd_vec'.
* configure: Regenerate.
* elf32-mips.c: New target for FreeBSD support
(same as traditional MIPS but overrides ELF_OSABI
with ELFOSABI_FREEBSD).
* elf64-mips.c: Likewise.
* elfn32-mips.c: Likewise.
* targets.c (_bfd_target_vector): Add
`bfd_elf32_ntradbigmips_freebsd_vec',
`bfd_elf32_ntradlittlemips_freebsd_vec',
`bfd_elf32_tradbigmips_freebsd_vec',
`bfd_elf32_tradlittlemips_freebsd_vec',
`bfd_elf64_tradbigmips_freebsd_vec' and
`bfd_elf64_tradlittlemips_freebsd_vec'.
ld/
2010-12-14 Robert Millan <rmh@gnu.org>
* configure.tgt: Recognize mips-freebsd and mips-kfreebsd-gnu.
* emulparams/elf32btsmip_fbsd.sh: New file.
* emulparams/elf32btsmipn32_fbsd.sh: Likewise.
* emulparams/elf32ltsmip_fbsd.sh: Likewise.
* emulparams/elf32ltsmipn32_fbsd.sh: Likewise.
* emulparams/elf64btsmip_fbsd.sh: Likewise.
* emulparams/elf64ltsmip_fbsd.sh: Likewise.
* Makefile.am: Add build rules for `eelf32btsmip_fbsd.c',
`eelf32btsmipn32_fbsd.c', `eelf32ltsmip_fbsd.c',
`eelf32ltsmipn32_fbsd.c', `eelf64btsmip_fbsd.c' and
`eelf64ltsmip_fbsd.c'.
* Makefile.in: Regenerate.
gas/
2010-12-19 Robert Millan <rmh@gnu.org>
Richard Sandiford <rdsandiford@googlemail.com>
* config/tc-mips.c (ELF_TARGET): New macro. Generates target
names accordingly to whether TE_FreeBSD and whether TE_TMIPS
are defined.
(mips_target_format): Refactor code using ELF_TARGET().
(support_64bit_objects): Likewise.
* configure.in: Recognize mips-freebsd and mips-kfreebsd-gnu.
* configure.tgt: Likewise.
* configure: Regenerate.
binutils/testsuite/
* binutils-all/readelf.exp: Handle MIPS FreeBSD targets.
gas/testsuite/
* gas/mips/e32el-rel2.d: Accept any file format.
* gas/mips/elf-rel.d: Likewise.
* gas/mips/elf-rel2.d: Likewise.
* gas/mips/elf-rel3.d: Likewise.
* gas/mips/elfel-rel.d: Likewise.
* gas/mips/elfel-rel2.d: Likewise.
* gas/mips/elfel-rel3.d: Likewise.
* gas/mips/ldstla-32-mips3-shared.d: Likewise.
* gas/mips/ldstla-32-mips3.d: Likewise.
* gas/mips/ldstla-32-shared.d: Likewise.
* gas/mips/ldstla-32.d: Likewise.
* gas/mips/ldstla-n64-shared.d: Likewise.
* gas/mips/ldstla-n64.d: Likewise.
* gas/mips/noat-1.d: Likewise.
* gas/mips/set-arch.d: Likewise.
* gas/mips/tls-o32.d: Likewise.
ld/testsuite/
* ld-mips-elf/mips-elf-flags.exp: Handle FreeBSD targets.
* ld-mips-elf/mips-elf.exp: Likewise.
* ld-mips-elf/mips16-call-global.d: Accept any file format.
* ld-mips-elf/mips16-intermix.d: Likewise.
2010-12-31 11:01:00 +00:00
|
|
|
|| [istarget "mips*-*freebsd*"] } then {
|
2001-05-25 18:58:10 +00:00
|
|
|
set target_machine tmips
|
|
|
|
} else {
|
|
|
|
set target_machine mips
|
|
|
|
}
|
2000-11-03 01:59:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if { $target_machine != "" && [file exists $srcdir/$subdir/$regexp_file-$readelf_size-$target_machine] } then {
|
|
|
|
set regexp_file $regexp_file-$readelf_size-$target_machine
|
|
|
|
} elseif { $target_machine != "" && [file exists $srcdir/$subdir/$regexp_file-$target_machine] } then {
|
|
|
|
set regexp_file $regexp_file-$target_machine
|
|
|
|
} elseif { [file exists $srcdir/$subdir/$regexp_file-$readelf_size] } then {
|
2000-06-14 01:21:35 +00:00
|
|
|
set regexp_file $regexp_file-$readelf_size
|
|
|
|
}
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
if { [regexp_diff readelf.out $srcdir/$subdir/$regexp_file] } then {
|
|
|
|
fail "readelf $options"
|
|
|
|
verbose "output is \n[file_contents readelf.out]" 2
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
pass "readelf $options"
|
|
|
|
}
|
|
|
|
|
2003-04-26 07:53:20 +00:00
|
|
|
# Simple proc to skip certain expected warning messages.
|
|
|
|
|
|
|
|
proc prune_readelf_wi_warnings { text } {
|
|
|
|
regsub -all "(^|\n)(.*Skipping unexpected symbol type.*)" $text "\\1" text
|
|
|
|
return $text
|
|
|
|
}
|
|
|
|
|
|
|
|
# Testing the "readelf -wi" option is difficult because there
|
|
|
|
# is no guaranteed order to the output, and because some ports
|
|
|
|
# will use indirect string references, whilst others will use
|
|
|
|
# direct references. So instead of having an expected output
|
|
|
|
# file, like the other readelf tests, we grep for strings that
|
|
|
|
# really ought to be there.
|
|
|
|
|
|
|
|
proc readelf_wi_test {} {
|
|
|
|
global READELF
|
|
|
|
global READELFFLAGS
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
2012-11-27 17:26:11 +00:00
|
|
|
|
2003-04-26 07:53:20 +00:00
|
|
|
# Compile the second test file.
|
|
|
|
if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } {
|
|
|
|
verbose "Unable to compile test file."
|
|
|
|
untested "readelf -wi"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
# Download it.
|
2004-05-12 03:28:46 +00:00
|
|
|
set tempfile [remote_download host tmpdir/testprog.o]
|
2003-04-26 07:53:20 +00:00
|
|
|
|
|
|
|
# Run "readelf -wi" on it.
|
2007-08-28 13:21:58 +00:00
|
|
|
set got [remote_exec host "$READELF $READELFFLAGS -wi $tempfile" "" "/dev/null" "readelf.out"]
|
2003-04-26 07:53:20 +00:00
|
|
|
|
|
|
|
# Upload the results.
|
2004-05-12 03:28:46 +00:00
|
|
|
set output [remote_upload host readelf.out]
|
2003-04-26 07:53:20 +00:00
|
|
|
|
2004-05-12 03:28:46 +00:00
|
|
|
file_on_host delete $tempfile
|
2012-11-27 17:26:11 +00:00
|
|
|
|
2003-04-26 07:53:20 +00:00
|
|
|
# Strip any superflous warnings.
|
2007-08-28 13:21:58 +00:00
|
|
|
set got [prune_readelf_wi_warnings [lindex $got 1]]
|
2003-04-26 07:53:20 +00:00
|
|
|
|
|
|
|
if ![string match "" $got] then {
|
2007-02-14 10:05:59 +00:00
|
|
|
fail "readelf $READELFFLAGS -wi (reason: unexpected output)"
|
2003-04-26 07:53:20 +00:00
|
|
|
send_log $got
|
|
|
|
send_log "\n"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if ![file size $output] then {
|
|
|
|
# If the output file is empty, then this target does not
|
|
|
|
# generate dwarf2 output. This is not a failure.
|
|
|
|
verbose "No output from 'readelf -wi'"
|
|
|
|
untested "readelf -wi"
|
|
|
|
return
|
|
|
|
}
|
2012-11-27 17:26:11 +00:00
|
|
|
|
2003-04-26 07:53:20 +00:00
|
|
|
# Search for strings that should be in the output.
|
|
|
|
set sought {
|
|
|
|
".*DW_TAG_compile_unit.*"
|
|
|
|
".*DW_TAG_subprogram.*"
|
|
|
|
".*DW_TAG_base_type.*"
|
|
|
|
".*DW_AT_producer.*(GNU C|indirect string).*"
|
|
|
|
".*DW_AT_language.*ANSI C.*"
|
|
|
|
".*DW_AT_name.*(testprog.c|indirect string).*"
|
|
|
|
".*DW_AT_name.*fn.*"
|
|
|
|
".*DW_AT_name.*(main|indirect string).*"
|
2003-04-26 07:57:26 +00:00
|
|
|
".*\(DW_OP_addr: 0\).*"
|
2003-04-26 07:53:20 +00:00
|
|
|
}
|
2012-11-27 17:26:11 +00:00
|
|
|
|
2013-05-02 21:06:15 +00:00
|
|
|
# The MSP430 in LARGE mode does not generate a DW_OP_addr.
|
|
|
|
setup_xfail msp430*-*-*
|
|
|
|
|
2012-11-27 17:26:11 +00:00
|
|
|
foreach looked_for $sought {
|
2003-04-26 07:53:20 +00:00
|
|
|
set lines [grep $output $looked_for]
|
|
|
|
if ![llength $lines] then {
|
|
|
|
fail "readelf -wi: missing: $looked_for"
|
|
|
|
send_log readelf.out
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-12 03:28:46 +00:00
|
|
|
file_on_host delete $output
|
2012-11-27 17:26:11 +00:00
|
|
|
|
2003-04-26 07:53:20 +00:00
|
|
|
# All done.
|
|
|
|
pass "readelf -wi"
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
2008-07-10 01:32:23 +00:00
|
|
|
# This tests "readelf -wa", but on a file with a compressed
|
|
|
|
# .debug_abbrev section.
|
|
|
|
|
|
|
|
proc readelf_compressed_wa_test {} {
|
|
|
|
global READELF
|
|
|
|
global READELFFLAGS
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
2012-11-27 17:26:11 +00:00
|
|
|
|
2008-07-10 01:32:23 +00:00
|
|
|
# Compile the compressed-debug-section test file.
|
|
|
|
if { [target_compile $srcdir/$subdir/dw2-compressed.S tmpdir/dw2-compressed.o object debug] != "" } {
|
|
|
|
verbose "Unable to compile test file."
|
|
|
|
untested "readelf -wa (compressed)"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
# Download it.
|
|
|
|
set tempfile [remote_download host tmpdir/dw2-compressed.o]
|
|
|
|
|
|
|
|
# Run "readelf -wa" on it.
|
|
|
|
set got [remote_exec host "$READELF $READELFFLAGS -wa $tempfile" "" "/dev/null" "readelf.out"]
|
|
|
|
|
|
|
|
# Upload the results.
|
|
|
|
set output [remote_upload host readelf.out]
|
|
|
|
|
|
|
|
file_on_host delete $tempfile
|
2012-11-27 17:26:11 +00:00
|
|
|
|
2008-07-10 01:32:23 +00:00
|
|
|
if { [string compare [file_contents readelf.out] [file_contents $srcdir/$subdir/readelf.wa]] != 0 } then {
|
|
|
|
fail "readelf -wa (compressed)"
|
|
|
|
verbose "output is \n[file_contents readelf.out]" 2
|
|
|
|
verbose "expected is \n[file_contents $srcdir/$subdir/readelf.wa]" 2
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
pass "readelf -wa (compressed)"
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
2007-08-30 13:47:35 +00:00
|
|
|
# Test readelf's dumping abilities.
|
|
|
|
|
|
|
|
proc readelf_dump_test {} {
|
|
|
|
global READELF
|
|
|
|
global READELFFLAGS
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
2012-11-27 17:26:11 +00:00
|
|
|
|
2007-08-30 13:47:35 +00:00
|
|
|
# Assemble the dump test file.
|
|
|
|
if {![binutils_assemble $srcdir/$subdir/dumptest.s tmpdir/dumptest.o]} then {
|
|
|
|
unresolved "readelf -p: failed to assemble dump test file"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
# Download it.
|
|
|
|
set tempfile [remote_download host tmpdir/dumptest.o]
|
|
|
|
|
|
|
|
# Run "readelf -p.data" on it.
|
|
|
|
set got [remote_exec host "$READELF $READELFFLAGS -p.data $tempfile" "" "/dev/null" "readelf.out"]
|
|
|
|
set got [lindex $got 1]
|
|
|
|
|
|
|
|
# Upload the results.
|
|
|
|
set output [remote_upload host readelf.out]
|
|
|
|
|
|
|
|
# Check for something going wrong.
|
|
|
|
if ![string match "" $got] then {
|
|
|
|
fail "readelf -p: unexpected output"
|
|
|
|
send_log $got
|
|
|
|
send_log "\n"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
# Search for strings that should be in the output.
|
|
|
|
set sought {
|
|
|
|
".*test_string.*"
|
|
|
|
}
|
2012-11-27 17:26:11 +00:00
|
|
|
|
|
|
|
foreach looked_for $sought {
|
2007-08-30 13:47:35 +00:00
|
|
|
set lines [grep $output $looked_for]
|
|
|
|
if ![llength $lines] then {
|
|
|
|
fail "readelf -p: missing: $looked_for"
|
|
|
|
send_log readelf.out
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-27 17:26:11 +00:00
|
|
|
file_on_host delete $tempfile
|
2007-08-30 13:47:35 +00:00
|
|
|
file_on_host delete $output
|
|
|
|
|
|
|
|
# All done.
|
|
|
|
pass "readelf -p"
|
|
|
|
|
|
|
|
# XXX FIXME: Add test of readelf -x here
|
1999-05-03 07:29:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ![is_remote host] {
|
|
|
|
if {[which $READELF] == 0} then {
|
|
|
|
perror "$READELF does not exist"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
send_user "Version [binutil_version $READELF]"
|
|
|
|
|
2001-06-21 07:44:32 +00:00
|
|
|
# Assemble the test file.
|
1999-05-03 07:29:11 +00:00
|
|
|
if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
|
2007-08-30 13:47:35 +00:00
|
|
|
perror "could not assemble test file"
|
1999-05-03 07:29:11 +00:00
|
|
|
unresolved "readelf - failed to assemble"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if ![is_remote host] {
|
2004-05-12 03:28:46 +00:00
|
|
|
set tempfile tmpdir/bintest.o
|
1999-05-03 07:29:11 +00:00
|
|
|
} else {
|
|
|
|
set tempfile [remote_download host tmpdir/bintest.o]
|
|
|
|
}
|
|
|
|
|
2000-06-14 01:21:35 +00:00
|
|
|
# First, determine the size, so specific output matchers can be used.
|
|
|
|
readelf_find_size $tempfile
|
|
|
|
|
|
|
|
# Run the tests.
|
1999-05-03 07:29:11 +00:00
|
|
|
readelf_test -h $tempfile readelf.h {}
|
2000-11-03 01:59:12 +00:00
|
|
|
readelf_test -S $tempfile readelf.s {}
|
|
|
|
readelf_test -s $tempfile readelf.ss {}
|
1999-05-03 07:29:11 +00:00
|
|
|
readelf_test -r $tempfile readelf.r {}
|
|
|
|
|
2003-04-26 07:53:20 +00:00
|
|
|
readelf_wi_test
|
2008-07-10 01:32:23 +00:00
|
|
|
readelf_compressed_wa_test
|
2007-08-30 13:47:35 +00:00
|
|
|
|
|
|
|
readelf_dump_test
|
2012-02-01 15:44:30 +00:00
|
|
|
|
|
|
|
# PR 13482 - Check for off-by-one errors when dumping .note sections.
|
|
|
|
if {![binutils_assemble $srcdir/$subdir/version.s tmpdir/version.o]} then {
|
|
|
|
perror "could not assemble version note test file"
|
|
|
|
unresolved "readelf - failed to assemble"
|
2015-05-15 16:16:31 +00:00
|
|
|
fail "readelf -n"
|
2012-02-01 15:44:30 +00:00
|
|
|
} else {
|
2015-05-15 16:16:31 +00:00
|
|
|
|
|
|
|
if ![is_remote host] {
|
|
|
|
set tempfile tmpdir/version.o
|
|
|
|
} else {
|
|
|
|
set tempfile [remote_download host tmpdir/version.o]
|
|
|
|
}
|
|
|
|
|
|
|
|
readelf_test -n $tempfile readelf.n {}
|
2012-02-01 15:44:30 +00:00
|
|
|
}
|
|
|
|
|
2015-05-15 10:21:38 +00:00
|
|
|
|
|
|
|
# PR 18374 - Check that relocations against the .debug_loc section
|
|
|
|
# do not prevent readelf from displaying all the location lists.
|
|
|
|
if {![binutils_assemble $srcdir/$subdir/pr18374.s tmpdir/pr18374.o]} then {
|
|
|
|
perror "could not assemble PR18374 test file"
|
|
|
|
unresolved "readelf - failed to assemble"
|
2015-05-15 16:16:31 +00:00
|
|
|
fail "readelf --debug-loc"
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if ![is_remote host] {
|
|
|
|
set tempfile tmpdir/pr18374.o
|
|
|
|
} else {
|
|
|
|
set tempfile [remote_download host tmpdir/pr18374.o]
|
|
|
|
}
|
|
|
|
|
|
|
|
readelf_test --debug-dump=loc $tempfile readelf.pr18374 {}
|
2015-05-15 10:21:38 +00:00
|
|
|
}
|
|
|
|
|
2015-05-15 16:16:31 +00:00
|
|
|
|
|
|
|
# Check that decompressed dumps work.
|
|
|
|
if {![binutils_assemble $srcdir/$subdir/z.s tmpdir/z.o]} then {
|
|
|
|
perror "could not assemble decompress dump test file"
|
|
|
|
unresolved "readelf - failed to assemble"
|
|
|
|
fail "readelf -z"
|
2015-05-15 10:21:38 +00:00
|
|
|
} else {
|
|
|
|
|
2015-05-15 16:16:31 +00:00
|
|
|
if ![is_remote host] {
|
|
|
|
set tempfile tmpdir/z.o
|
|
|
|
} else {
|
|
|
|
set tempfile [remote_download host tmpdir/z.o]
|
|
|
|
}
|
|
|
|
|
|
|
|
readelf_test {--decompress --hex-dump .debug_loc} $tempfile readelf.z {}
|
|
|
|
}
|