X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=binutils%2Ftestsuite%2Fbinutils-all%2Freadelf.exp;h=cb924317bcc8ca4e9d15f7ee9cd7a6ae9c9215c3;hb=80fda85ca18ee287c826a90b09c5cb8e20fd4d54;hp=2a6bc6ab5c7c19cbc8139302db5120c4a575564c;hpb=4b95cf5c0c75d6efc1b2f96af72317aecca079f1;p=thirdparty%2Fbinutils-gdb.git diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsuite/binutils-all/readelf.exp index 2a6bc6ab5c7..cb924317bcc 100644 --- a/binutils/testsuite/binutils-all/readelf.exp +++ b/binutils/testsuite/binutils-all/readelf.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # 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 @@ -40,13 +40,13 @@ proc file_contents { filename } { # 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 } { +proc readelf_find_size { binary_file test_iteration } { global READELF global READELFFLAGS global readelf_size set readelf_size "" - set testname "finding out ELF size with readelf -h" + set testname "finding out ELF size with readelf -h ($test_iteration)" set got [remote_exec host "$READELF $READELFFLAGS -h $binary_file" "" "/dev/null" "readelf.out"] if [is_remote host] then { remote_upload host "readelf.out" @@ -84,6 +84,8 @@ proc readelf_test { options binary_file regexp_file xfails } { global srcdir global subdir + set testname "readelf $options [file rootname [file tail $binary_file]]" + send_log "exec $READELF $READELFFLAGS $options $binary_file > readelf.out\n" set got [remote_exec host "$READELF $READELFFLAGS $options $binary_file" "" "/dev/null" "readelf.out"] @@ -92,7 +94,7 @@ proc readelf_test { options binary_file regexp_file xfails } { } if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { - fail "readelf $options (reason: unexpected output)" + fail "$testname (reason: unexpected output)" send_log $got send_log "\n" return @@ -100,13 +102,10 @@ proc readelf_test { options binary_file regexp_file xfails } { set target_machine "" if [istarget "mips*-*-*"] then { - if { [istarget "mips*-*-*linux*"] - || [istarget "mips*-sde-elf*"] - || [istarget "mips*-mti-elf*"] - || [istarget "mips*-*freebsd*"] } then { - set target_machine tmips - } else { + if [is_bad_symtab] then { set target_machine mips + } else { + set target_machine tmips } } @@ -119,12 +118,12 @@ proc readelf_test { options binary_file regexp_file xfails } { } if { [regexp_diff readelf.out $srcdir/$subdir/$regexp_file] } then { - fail "readelf $options" + fail $testname verbose "output is \n[file_contents readelf.out]" 2 return } - pass "readelf $options" + pass $testname } # Simple proc to skip certain expected warning messages. @@ -223,11 +222,6 @@ proc readelf_compressed_wa_test {} { global srcdir global subdir - if { ![is_zlib_supported] } { - unsupported "readelf -wa (compressed)" - return - } - # 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." @@ -273,7 +267,12 @@ proc readelf_dump_test {} { 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 sect_names [get_standard_section_names] + if { $sect_names != "" } { + set got [remote_exec host "$READELF $READELFFLAGS -p[lindex $sect_names 1] $tempfile" "" "/dev/null" "readelf.out"] + } else { + set got [remote_exec host "$READELF $READELFFLAGS -p.data $tempfile" "" "/dev/null" "readelf.out"] + } set got [lindex $got 1] # Upload the results. @@ -321,42 +320,214 @@ send_user "Version [binutil_version $READELF]" # Assemble the test file. if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then { - perror "could not assemble test file" - unresolved "readelf - failed to assemble" - return -} - -if ![is_remote host] { - set tempfile tmpdir/bintest.o + unresolved "readelf -h bintest (failed to assemble)" + unresolved "readelf -S bintest (failed to assemble)" + unresolved "readelf -s bintest (failed to assemble)" + unresolved "readelf -r bintest (failed to assemble)" + global readelf_size + set readelf_size "" } else { - set tempfile [remote_download host tmpdir/bintest.o] -} -# First, determine the size, so specific output matchers can be used. -readelf_find_size $tempfile + if ![is_remote host] { + set tempfile tmpdir/bintest.o + } else { + set tempfile [remote_download host tmpdir/bintest.o] + } + + # First, determine the size, so specific output matchers can be used. + readelf_find_size $tempfile 1 -# Run the tests. -readelf_test -h $tempfile readelf.h {} -readelf_test -S $tempfile readelf.s {} -readelf_test -s $tempfile readelf.ss {} -readelf_test -r $tempfile readelf.r {} + # Run the tests. + readelf_test -h $tempfile readelf.h {} + readelf_test -S $tempfile readelf.s {} + setup_xfail "mips-*-*irix*" + readelf_test -s $tempfile readelf.ss {} + readelf_test -r $tempfile readelf.r {} +} readelf_wi_test readelf_compressed_wa_test readelf_dump_test +run_dump_test "pr25543" # 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" - return + unresolved "readelf -n version (failed to assemble)" +} else { + + if ![is_remote host] { + set tempfile tmpdir/version.o + } else { + set tempfile [remote_download host tmpdir/version.o] + } + + readelf_test -n $tempfile readelf.n {} } -if ![is_remote host] { - set tempfile tmpdir/version.o + +# 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 { + unresolved "readelf --debug-dump=loc pr18374 (failed to assemble)" +} 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 {} +} + + +# locview - Check dumping of location lists with location views. +if {![binutils_assemble $srcdir/$subdir/locview-1.s tmpdir/locview-1.o]} then { + unresolved "readelf --debug-dump=loc locview-1 (failed to assemble)" +} else { + + if ![is_remote host] { + set tempfile tmpdir/locview-1.o + } else { + set tempfile [remote_download host tmpdir/locview-1.o] + } + + readelf_test --debug-dump=loc $tempfile readelf.locview-1 {} +} +if {![binutils_assemble $srcdir/$subdir/locview-2.s tmpdir/locview-2.o]} then { + unresolved "readelf --debug-dump=loc locview-2 (failed to assemble)" +} else { + + if ![is_remote host] { + set tempfile tmpdir/locview-2.o + } else { + set tempfile [remote_download host tmpdir/locview-2.o] + } + + readelf_test --debug-dump=loc $tempfile readelf.locview-2 {} +} + + +# Check that decompressed dumps work. +if {![binutils_assemble $srcdir/$subdir/z.s tmpdir/z.o]} then { + unresolved "readelf --decompress --hex-dump .debug_loc z (failed to assemble)" +} else { + + 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 {} +} + +# Skip the next test for the RISCV architectures because they +# do not support .ULEB128 pseudo-ops with non-constant values. +if ![istarget "riscv*-*-*"] then { + + set hpux "" + if [istarget "hppa*64*-*-hpux*"] { + set hpux "--defsym HPUX=1" + } + + # Assemble the DWARF-5 test file. + if {![binutils_assemble_flags $srcdir/$subdir/dw5.S tmpdir/dw5.o $hpux]} then { + unresolved "readelf -wiaoRlL dw5 (failed to assemble)" + } else { + + # Download it. + if ![is_remote host] { + set tempfile tmpdir/dw5.o + } else { + set tempfile [remote_download host tmpdir/dw5.o] + } + + # First, determine the size, so specific output matchers can be used. + readelf_find_size $tempfile 2 + + # Make sure that readelf can decode the contents. + readelf_test -wiaoRlL $tempfile dw5.W { nds32*-elf } + } +} + +# Assemble the DWARF-5 attributes test file. +if {![binutils_assemble_flags $srcdir/$subdir/dwarf-attributes.S tmpdir/dwarf-attributes.o ""]} then { + unresolved "readelf -wi dwarf-attributes (failed to assemble)" +} else { + # Download it. + if ![is_remote host] { + set tempfile tmpdir/dwarf-attributes.o + } else { + set tempfile [remote_download host tmpdir/dwarf-attributes.o] + } + + # First, determine the size, so specific output matchers can be used. + readelf_find_size $tempfile 3 + + # Make sure that readelf can decode the contents. + readelf_test -wi $tempfile dwarf-attributes.W {} +} + +# Check that debug link sections can be dumped. +if {![binutils_assemble $srcdir/$subdir/debuglink.s tmpdir/debuglink.o]} then { + unresolved "readelf --debug-dump=links (failed to assemble debuglink.s)" +} else { + if ![is_remote host] { + set tempfile tmpdir/debuglink.o + } else { + set tempfile [remote_download host tmpdir/debuglink.o] + } + + readelf_test {--debug-dump=links} $tempfile readelf.k {} + + # Check that debug link sections can be followed. + if {![binutils_assemble $srcdir/$subdir/linkdebug.s tmpdir/linkdebug.debug]} then { + unresolved "readelf --debug-dump=follow-links (failed to assemble linkdebug.s)" + } else { + if [is_remote host] { + set tempfile2 [remote_download host tmpdir/linkdebug.debug] + } + + readelf_test {-wKis} $tempfile readelf.wKis {} + } +} + +if {![binutils_assemble $srcdir/$subdir/dwo.s tmpdir/dwo.o]} then { + unresolved "readelf --debug-dump=links (failed to assemble dwo.s)" } else { - set tempfile [remote_download host tmpdir/version.o] + if ![is_remote host] { + set tempfile tmpdir/dwo.o + } else { + set tempfile [remote_download host tmpdir/dwo.o] + } + + readelf_test {--debug-dump=links} $tempfile readelf.k2 {} } -readelf_test -n $tempfile readelf.n {} +if {![binutils_assemble $srcdir/$subdir/zero-sec.s tmpdir/zero-sec.o]} then { + unresolved "readelf --enable-checks (failed to assemble zero-sec.s)" +} else { + if ![is_remote host] { + set tempfile tmpdir/zero-sec.o + } else { + set tempfile [remote_download host tmpdir/zero-sec.o] + } + + readelf_test {--enable-checks --sections --wide} $tempfile zero-sec.r {} +} + +if ![is_remote host] { + set test $srcdir/$subdir/pr26112.o.bz2 + # We need to strip the ".bz2", but can leave the dirname. + set t $subdir/[file tail $test] + set testname [file rootname $t] + verbose $testname + set tempfile tmpdir/pr26112.o + if {[catch "system \"bzip2 -dc $test > $tempfile\""] != 0} { + untested "bzip2 -dc ($testname)" + } else { + readelf_test {--debug-dump=macro} $tempfile pr26112.r {} + } +}