+proc readelf_compressed_wa_test {} {
+ global READELF
+ global READELFFLAGS
+ global srcdir
+ global subdir
+
+ # 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
+
+ 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)"
+}
+
+# Test readelf's dumping abilities.
+
+proc readelf_dump_test {} {
+ global READELF
+ global READELFFLAGS
+ global srcdir
+ global subdir
+
+ # 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.*"
+ }
+
+ foreach looked_for $sought {
+ set lines [grep $output $looked_for]
+ if ![llength $lines] then {
+ fail "readelf -p: missing: $looked_for"
+ send_log readelf.out
+ return
+ }
+ }
+
+ file_on_host delete $tempfile
+ file_on_host delete $output
+
+ # All done.
+ pass "readelf -p"
+
+ # XXX FIXME: Add test of readelf -x here