1 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
17 # Test compressed .debug section.
19 if { [is_remote host] || ![is_elf_format] || ![is_zlib_supported] } then {
23 set testfile tmpdir/dw2-1.o
24 set compressedfile tmpdir/dw2-1-compressed.o
25 set copyfile tmpdir/dw2-copy
26 set compressedfile2 tmpdir/dw2-2-compressed.o
27 set libfile tmpdir/libdw2.a
28 set compressedcopyfile tmpdir/dw2-copy-compressed
30 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S $testfile --nocompress-debug-sections] } then {
31 unsupported "compressed debug sections"
35 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S $compressedfile --compress-debug-sections] } then {
36 unsupported "compressed debug sections"
40 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S $compressedfile2 --compress-debug-sections] } then {
41 unsupported "compressed debug sections"
45 remote_file host delete $libfile
46 set got [binutils_run $AR "rc $libfile $compressedfile $compressedfile2"]
47 if ![string match "" $got] then {
48 fail "compressed debug sections"
52 set testname "objcopy compress debug sections"
53 set got [binutils_run $OBJCOPY "--compress-debug-sections $testfile ${copyfile}.o"]
54 if ![string match "" $got] then {
55 fail "objcopy ($testname)"
57 send_log "cmp $compressedfile ${copyfile}.o\n"
58 verbose "cmp $compressedfile ${copyfile}.o"
59 set src1 ${compressedfile}
60 set src2 ${copyfile}.o
61 set status [remote_exec build cmp "${src1} ${src2}"]
62 set exec_output [lindex $status 1]
63 set exec_output [prune_warnings $exec_output]
65 if [string match "" $exec_output] then {
66 pass "objcopy ($testname)"
68 send_log "$exec_output\n"
69 verbose "$exec_output" 1
70 fail "objcopy ($testname)"
74 set testname "objcopy decompress compressed debug sections"
75 set got [binutils_run $OBJCOPY "--decompress-debug-sections $compressedfile ${copyfile}.o"]
76 if ![string match "" $got] then {
77 fail "objcopy ($testname)"
79 send_log "cmp $testfile ${copyfile}.o\n"
80 verbose "cmp $testfile ${copyfile}.o"
82 set src2 ${copyfile}.o
83 set status [remote_exec build cmp "${src1} ${src2}"]
84 set exec_output [lindex $status 1]
85 set exec_output [prune_warnings $exec_output]
87 if [string match "" $exec_output] then {
88 pass "objcopy ($testname)"
90 send_log "$exec_output\n"
91 verbose "$exec_output" 1
92 fail "objcopy ($testname)"
96 set testname "objcopy decompress debug sections in archive"
97 set got [binutils_run $OBJCOPY "--decompress-debug-sections $libfile ${copyfile}.a"]
98 if ![string match "" $got] then {
99 fail "objcopy ($testname)"
101 set got [remote_exec host "$READELF -S --wide ${copyfile}.a" "" "/dev/null" "tmpdir/libdw2.out"]
103 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
104 fail "$testname (reason: unexpected output)"
109 if { [regexp_diff tmpdir/libdw2.out $srcdir/$subdir/libdw2.out] } then {
116 set testname "objcopy compress debug sections in archive"
117 set got [binutils_run $OBJCOPY "--compress-debug-sections ${copyfile}.a ${compressedcopyfile}.a"]
118 if ![string match "" $got] then {
119 fail "objcopy ($testname)"
121 set got [remote_exec host "$OBJDUMP -s -j .zdebug_line ${compressedcopyfile}.a" "" "/dev/null" "tmpdir/libdw2-compressed.out"]
123 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
124 fail "$testname (reason: unexpected output)"
129 if { [regexp_diff tmpdir/libdw2-compressed.out $srcdir/$subdir/libdw2-compressed.out] } then {
136 set testname "objdump compress debug sections"
137 set got [remote_exec host "$OBJDUMP -W $compressedfile" "" "/dev/null" "objdump.out"]
138 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
142 if { [regexp_diff objdump.out $srcdir/$subdir/dw2-1.W] } then {
148 set testfile tmpdir/dw2-emty.o
150 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-empty.S $testfile --nocompress-debug-sections] } then {
151 unsupported "compressed debug sections"
155 set testname "objcopy compress empty debug sections"
156 set got [binutils_run $OBJCOPY "--compress-debug-sections $testfile ${copyfile}.o"]
157 if ![string match "" $got] then {
158 fail "objcopy ($testname)"
160 send_log "cmp $testfile ${copyfile}.o\n"
161 verbose "cmp $testfile ${copyfile}.o"
163 set src2 ${copyfile}.o
164 set status [remote_exec build cmp "${src1} ${src2}"]
165 set exec_output [lindex $status 1]
166 set exec_output [prune_warnings $exec_output]
168 if [string match "" $exec_output] then {
169 pass "objcopy ($testname)"
171 send_log "$exec_output\n"
172 verbose "$exec_output" 1
173 fail "objcopy ($testname)"
177 if ![is_remote host] {
178 set tempfile tmpdir/debug_str.o
179 set copyfile tmpdir/debug_str.copy
181 set tempfile [remote_download host tmpdir/debug_str.o]
182 set copyfile debug_str.copy
185 run_dump_test "debug_str"