1 |
15 |
khays |
# Copyright 2010
|
2 |
|
|
# Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
# This program is free software; you can redistribute it and/or modify
|
5 |
|
|
# it under the terms of the GNU General Public License as published by
|
6 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
7 |
|
|
# (at your option) any later version.
|
8 |
|
|
#
|
9 |
|
|
# This program is distributed in the hope that it will be useful,
|
10 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
|
|
# GNU General Public License for more details.
|
13 |
|
|
#
|
14 |
|
|
# You should have received a copy of the GNU General Public License
|
15 |
|
|
# along with this program; if not, write to the Free Software
|
16 |
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
17 |
|
|
|
18 |
|
|
# Test compressed .debug section.
|
19 |
|
|
|
20 |
|
|
if { [is_remote host] || ![is_elf_format] } then {
|
21 |
|
|
return
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
set testfile tmpdir/dw2-1.o
|
25 |
|
|
set compressedfile tmpdir/dw2-1-compressed.o
|
26 |
|
|
set copyfile tmpdir/dw2-copy
|
27 |
|
|
set compressedfile2 tmpdir/dw2-2-compressed.o
|
28 |
|
|
set libfile tmpdir/libdw2.a
|
29 |
|
|
set compressedcopyfile tmpdir/dw2-copy-compressed
|
30 |
|
|
|
31 |
|
|
if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S $testfile --nocompress-debug-sections] } then {
|
32 |
|
|
unsupported "compressed debug sections"
|
33 |
|
|
return
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S $compressedfile --compress-debug-sections] } then {
|
37 |
|
|
unsupported "compressed debug sections"
|
38 |
|
|
return
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S $compressedfile2 --compress-debug-sections] } then {
|
42 |
|
|
unsupported "compressed debug sections"
|
43 |
|
|
return
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
remote_file host delete $libfile
|
47 |
|
|
set got [binutils_run $AR "rc $libfile $compressedfile $compressedfile2"]
|
48 |
|
|
if ![string match "" $got] then {
|
49 |
|
|
fail "compressed debug sections"
|
50 |
|
|
return
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
set testname "objcopy compress debug sections"
|
54 |
|
|
set got [binutils_run $OBJCOPY "--compress-debug-sections $testfile ${copyfile}.o"]
|
55 |
|
|
if ![string match "" $got] then {
|
56 |
|
|
fail "objcopy ($testname)"
|
57 |
|
|
} else {
|
58 |
|
|
send_log "cmp $compressedfile ${copyfile}.o\n"
|
59 |
|
|
verbose "cmp $compressedfile ${copyfile}.o"
|
60 |
|
|
set src1 ${compressedfile}
|
61 |
|
|
set src2 ${copyfile}.o
|
62 |
|
|
set status [remote_exec build cmp "${src1} ${src2}"]
|
63 |
|
|
set exec_output [lindex $status 1]
|
64 |
|
|
set exec_output [prune_warnings $exec_output]
|
65 |
|
|
|
66 |
|
|
if [string match "" $exec_output] then {
|
67 |
|
|
pass "objcopy ($testname)"
|
68 |
|
|
} else {
|
69 |
|
|
send_log "$exec_output\n"
|
70 |
|
|
verbose "$exec_output" 1
|
71 |
|
|
fail "objcopy ($testname)"
|
72 |
|
|
}
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
set testname "objcopy decompress compressed debug sections"
|
76 |
|
|
set got [binutils_run $OBJCOPY "--decompress-debug-sections $compressedfile ${copyfile}.o"]
|
77 |
|
|
if ![string match "" $got] then {
|
78 |
|
|
fail "objcopy ($testname)"
|
79 |
|
|
} else {
|
80 |
|
|
send_log "cmp $testfile ${copyfile}.o\n"
|
81 |
|
|
verbose "cmp $testfile ${copyfile}.o"
|
82 |
|
|
set src1 ${testfile}
|
83 |
|
|
set src2 ${copyfile}.o
|
84 |
|
|
set status [remote_exec build cmp "${src1} ${src2}"]
|
85 |
|
|
set exec_output [lindex $status 1]
|
86 |
|
|
set exec_output [prune_warnings $exec_output]
|
87 |
|
|
|
88 |
|
|
if [string match "" $exec_output] then {
|
89 |
|
|
pass "objcopy ($testname)"
|
90 |
|
|
} else {
|
91 |
|
|
send_log "$exec_output\n"
|
92 |
|
|
verbose "$exec_output" 1
|
93 |
|
|
fail "objcopy ($testname)"
|
94 |
|
|
}
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
set testname "objcopy decompress debug sections in archive"
|
98 |
|
|
set got [binutils_run $OBJCOPY "--decompress-debug-sections $libfile ${copyfile}.a"]
|
99 |
|
|
if ![string match "" $got] then {
|
100 |
|
|
fail "objcopy ($testname)"
|
101 |
|
|
} else {
|
102 |
|
|
set got [remote_exec host "$READELF -S --wide ${copyfile}.a" "" "/dev/null" "tmpdir/libdw2.out"]
|
103 |
|
|
|
104 |
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
105 |
|
|
fail "$testname (reason: unexpected output)"
|
106 |
|
|
send_log $got
|
107 |
|
|
send_log "\n"
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
if { [regexp_diff tmpdir/libdw2.out $srcdir/$subdir/libdw2.out] } then {
|
111 |
|
|
fail "$testname"
|
112 |
|
|
} else {
|
113 |
|
|
pass "$testname"
|
114 |
|
|
}
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
set testname "objcopy compress debug sections in archive"
|
118 |
|
|
set got [binutils_run $OBJCOPY "--compress-debug-sections ${copyfile}.a ${compressedcopyfile}.a"]
|
119 |
|
|
if ![string match "" $got] then {
|
120 |
|
|
fail "objcopy ($testname)"
|
121 |
|
|
} else {
|
122 |
|
|
set got [remote_exec host "$OBJDUMP -s -j .zdebug_line ${compressedcopyfile}.a" "" "/dev/null" "tmpdir/libdw2-compressed.out"]
|
123 |
|
|
|
124 |
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
125 |
|
|
fail "$testname (reason: unexpected output)"
|
126 |
|
|
send_log $got
|
127 |
|
|
send_log "\n"
|
128 |
|
|
}
|
129 |
|
|
|
130 |
|
|
if { [regexp_diff tmpdir/libdw2-compressed.out $srcdir/$subdir/libdw2-compressed.out] } then {
|
131 |
|
|
fail "$testname"
|
132 |
|
|
} else {
|
133 |
|
|
pass "$testname"
|
134 |
|
|
}
|
135 |
|
|
}
|