2015-01-01 14:15:26 +00:00
|
|
|
# Copyright (C) 2010-2015 Free Software Foundation, Inc.
|
2010-10-29 12:10:39 +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
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2012-11-27 17:26:11 +00:00
|
|
|
#
|
2010-10-29 12:10:39 +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
|
|
|
#
|
2010-10-29 12:10:39 +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
|
|
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
# Test compressed .debug section.
|
|
|
|
|
2012-11-27 17:26:11 +00:00
|
|
|
if { [is_remote host] || ![is_elf_format] || ![is_zlib_supported] } then {
|
2010-10-29 12:10:39 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2015-04-04 14:18:17 +00:00
|
|
|
set testfile tmpdir/dw2-1
|
|
|
|
set compressedfile tmpdir/dw2-1-compressed
|
2010-10-29 12:10:39 +00:00
|
|
|
set copyfile tmpdir/dw2-copy
|
2015-04-04 14:18:17 +00:00
|
|
|
set compressedfile2 tmpdir/dw2-2-compressed
|
|
|
|
set libfile tmpdir/libdw2
|
2010-10-29 12:10:39 +00:00
|
|
|
set compressedcopyfile tmpdir/dw2-copy-compressed
|
2015-04-04 14:18:17 +00:00
|
|
|
set testfile3 tmpdir/dw2-3
|
|
|
|
set compressedfile3 tmpdir/dw2-3-compressed
|
2010-10-29 12:10:39 +00:00
|
|
|
|
2015-04-04 14:18:17 +00:00
|
|
|
if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${testfile}.o --nocompress-debug-sections] } then {
|
2010-11-15 18:14:11 +00:00
|
|
|
unsupported "compressed debug sections"
|
2010-10-29 12:10:39 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2015-04-04 14:18:17 +00:00
|
|
|
if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}.o --compress-debug-sections] } then {
|
2010-10-29 12:10:39 +00:00
|
|
|
unsupported "compressed debug sections"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2015-04-04 14:18:17 +00:00
|
|
|
if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}.o --compress-debug-sections] } then {
|
2010-10-29 12:10:39 +00:00
|
|
|
unsupported "compressed debug sections"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2015-04-04 14:18:17 +00:00
|
|
|
if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${testfile3}.o --nocompress-debug-sections] } then {
|
|
|
|
unsupported "compressed debug sections"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}.o --compress-debug-sections] } then {
|
|
|
|
unsupported "compressed debug sections"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
remote_file host delete ${libfile}.a
|
|
|
|
set got [binutils_run $AR "rc ${libfile}.a ${compressedfile}.o ${compressedfile2}.o ${compressedfile3}.o"]
|
2010-10-29 12:10:39 +00:00
|
|
|
if ![string match "" $got] then {
|
|
|
|
fail "compressed debug sections"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set testname "objcopy compress debug sections"
|
2015-04-04 14:18:17 +00:00
|
|
|
set got [binutils_run $OBJCOPY "--compress-debug-sections ${testfile}.o ${copyfile}.o"]
|
2010-10-29 12:10:39 +00:00
|
|
|
if ![string match "" $got] then {
|
|
|
|
fail "objcopy ($testname)"
|
|
|
|
} else {
|
2015-04-04 14:18:17 +00:00
|
|
|
send_log "cmp ${compressedfile}.o ${copyfile}.o\n"
|
|
|
|
verbose "cmp ${compressedfile}.o ${copyfile}.o"
|
|
|
|
set src1 ${compressedfile}.o
|
2010-10-29 12:10:39 +00:00
|
|
|
set src2 ${copyfile}.o
|
|
|
|
set status [remote_exec build cmp "${src1} ${src2}"]
|
|
|
|
set exec_output [lindex $status 1]
|
|
|
|
set exec_output [prune_warnings $exec_output]
|
|
|
|
|
|
|
|
if [string match "" $exec_output] then {
|
|
|
|
pass "objcopy ($testname)"
|
|
|
|
} else {
|
|
|
|
send_log "$exec_output\n"
|
|
|
|
verbose "$exec_output" 1
|
|
|
|
fail "objcopy ($testname)"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set testname "objcopy decompress compressed debug sections"
|
2015-04-04 14:18:17 +00:00
|
|
|
set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile}.o ${copyfile}.o"]
|
2010-10-29 12:10:39 +00:00
|
|
|
if ![string match "" $got] then {
|
|
|
|
fail "objcopy ($testname)"
|
|
|
|
} else {
|
2015-04-04 14:18:17 +00:00
|
|
|
send_log "cmp ${testfile}.o ${copyfile}.o\n"
|
|
|
|
verbose "cmp ${testfile}.o ${copyfile}.o"
|
|
|
|
set src1 ${testfile}.o
|
2010-10-29 12:10:39 +00:00
|
|
|
set src2 ${copyfile}.o
|
|
|
|
set status [remote_exec build cmp "${src1} ${src2}"]
|
|
|
|
set exec_output [lindex $status 1]
|
|
|
|
set exec_output [prune_warnings $exec_output]
|
|
|
|
|
|
|
|
if [string match "" $exec_output] then {
|
|
|
|
pass "objcopy ($testname)"
|
|
|
|
} else {
|
|
|
|
send_log "$exec_output\n"
|
|
|
|
verbose "$exec_output" 1
|
|
|
|
fail "objcopy ($testname)"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set testname "objcopy decompress debug sections in archive"
|
2015-04-04 14:18:17 +00:00
|
|
|
set got [binutils_run $OBJCOPY "--decompress-debug-sections ${libfile}.a ${copyfile}.a"]
|
2010-10-29 12:10:39 +00:00
|
|
|
if ![string match "" $got] then {
|
|
|
|
fail "objcopy ($testname)"
|
|
|
|
} else {
|
|
|
|
set got [remote_exec host "$READELF -S --wide ${copyfile}.a" "" "/dev/null" "tmpdir/libdw2.out"]
|
|
|
|
|
|
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
|
|
|
fail "$testname (reason: unexpected output)"
|
|
|
|
send_log $got
|
|
|
|
send_log "\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
if { [regexp_diff tmpdir/libdw2.out $srcdir/$subdir/libdw2.out] } then {
|
|
|
|
fail "$testname"
|
|
|
|
} else {
|
|
|
|
pass "$testname"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set testname "objcopy compress debug sections in archive"
|
|
|
|
set got [binutils_run $OBJCOPY "--compress-debug-sections ${copyfile}.a ${compressedcopyfile}.a"]
|
|
|
|
if ![string match "" $got] then {
|
|
|
|
fail "objcopy ($testname)"
|
|
|
|
} else {
|
|
|
|
set got [remote_exec host "$OBJDUMP -s -j .zdebug_line ${compressedcopyfile}.a" "" "/dev/null" "tmpdir/libdw2-compressed.out"]
|
|
|
|
|
|
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
|
|
|
fail "$testname (reason: unexpected output)"
|
|
|
|
send_log $got
|
|
|
|
send_log "\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
if { [regexp_diff tmpdir/libdw2-compressed.out $srcdir/$subdir/libdw2-compressed.out] } then {
|
|
|
|
fail "$testname"
|
|
|
|
} else {
|
|
|
|
pass "$testname"
|
|
|
|
}
|
|
|
|
}
|
2012-07-03 16:06:34 +00:00
|
|
|
|
2012-10-20 22:14:08 +00:00
|
|
|
set testname "objdump compress debug sections"
|
2015-04-04 14:18:17 +00:00
|
|
|
set got [remote_exec host "$OBJDUMP -W ${compressedfile}.o" "" "/dev/null" "objdump.out"]
|
2012-10-20 22:14:08 +00:00
|
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
|
|
|
fail "$testname"
|
|
|
|
send_log "$got\n"
|
|
|
|
}
|
|
|
|
if { [regexp_diff objdump.out $srcdir/$subdir/dw2-1.W] } then {
|
|
|
|
fail "$testname"
|
|
|
|
} else {
|
|
|
|
pass "$testname"
|
|
|
|
}
|
|
|
|
|
2015-04-04 14:18:17 +00:00
|
|
|
set testname "objdump compress debug sections 3"
|
|
|
|
set got [remote_exec host "$OBJDUMP -W ${compressedfile3}.o" "" "/dev/null" "objdump.out"]
|
|
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
|
|
|
fail "$testname"
|
|
|
|
send_log "$got\n"
|
|
|
|
}
|
|
|
|
if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3.W] } then {
|
|
|
|
fail "$testname"
|
|
|
|
} else {
|
|
|
|
pass "$testname"
|
|
|
|
}
|
2012-07-03 16:06:34 +00:00
|
|
|
|
2015-04-04 14:18:17 +00:00
|
|
|
if { ![binutils_assemble_flags $srcdir/$subdir/dw2-empty.S ${testfile}empty.o --nocompress-debug-sections] } then {
|
2012-07-03 16:06:34 +00:00
|
|
|
unsupported "compressed debug sections"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set testname "objcopy compress empty debug sections"
|
2015-04-04 14:18:17 +00:00
|
|
|
set got [binutils_run $OBJCOPY "--compress-debug-sections ${testfile}empty.o ${copyfile}empty.o"]
|
2012-07-03 16:06:34 +00:00
|
|
|
if ![string match "" $got] then {
|
|
|
|
fail "objcopy ($testname)"
|
|
|
|
} else {
|
2015-04-04 14:18:17 +00:00
|
|
|
send_log "cmp ${testfile}empty.o ${copyfile}empty.o\n"
|
|
|
|
verbose "cmp ${testfile}empty.o ${copyfile}empty.o"
|
|
|
|
set src1 ${testfile}empty.o
|
|
|
|
set src2 ${copyfile}empty.o
|
2012-07-03 16:06:34 +00:00
|
|
|
set status [remote_exec build cmp "${src1} ${src2}"]
|
|
|
|
set exec_output [lindex $status 1]
|
|
|
|
set exec_output [prune_warnings $exec_output]
|
|
|
|
|
|
|
|
if [string match "" $exec_output] then {
|
|
|
|
pass "objcopy ($testname)"
|
|
|
|
} else {
|
|
|
|
send_log "$exec_output\n"
|
|
|
|
verbose "$exec_output" 1
|
|
|
|
fail "objcopy ($testname)"
|
|
|
|
}
|
|
|
|
}
|
2014-04-30 16:04:04 +00:00
|
|
|
|
|
|
|
if ![is_remote host] {
|
|
|
|
set tempfile tmpdir/debug_str.o
|
|
|
|
set copyfile tmpdir/debug_str.copy
|
|
|
|
} else {
|
|
|
|
set tempfile [remote_download host tmpdir/debug_str.o]
|
|
|
|
set copyfile debug_str.copy
|
|
|
|
}
|
|
|
|
|
|
|
|
run_dump_test "debug_str"
|