]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-elf/compress.exp
Add --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-elf / compress.exp
1 # Expect script for ELF compressed debug section tests.
2 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
3 #
4 # This file is part of the GNU Binutils.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20 #
21
22 # Exclude non-ELF targets.
23
24 if ![is_elf_format] {
25 return
26 }
27
28 # The following tests require running the executable generated by ld.
29 if ![isnative] {
30 return
31 }
32
33 # Check if compiler works
34 if { [which $CC] == 0 } {
35 return
36 }
37
38 global as
39 if { ![ld_assemble $as "--compress-debug-sections $srcdir/$subdir/empty.s" tmpdir/empty.o ] } {
40 fail "linker compressed debug sections"
41 }
42
43 if { ![ld_assemble $as "--compress-debug-sections=zlib-gabi $srcdir/$subdir/empty.s" tmpdir/emptyzlib.o ] } {
44 fail "linker compressed debug sections"
45 }
46
47 set build_tests {
48 {"Build libfoo.so with compressed debug sections"
49 "-shared" "-fPIC -g -Wa,--compress-debug-sections"
50 {foo.c} {} "libfoo.so"}
51 {"Build libbar.so with compressed debug sections"
52 "-shared -Wl,--compress-debug-sections=none"
53 "-fPIC -g -Wa,--compress-debug-sections"
54 {begin.c end.c} {} "libbar.so"}
55 {"Build libfoozlib.so with compressed debug sections with zlib-gabi"
56 "-shared" "-fPIC -g -Wa,--compress-debug-sections=zlib-gabi"
57 {foo.c} {} "libfoozlib.so"}
58 {"Build libbarzlib.so with compressed debug sections with zlib-gabi"
59 "-shared" "-fPIC -g -Wa,--compress-debug-sections=zlib-gabi"
60 {begin.c end.c} {} "libbarzlib.so"}
61 {"Build libzlibfoo.so with zlib compressed debug sections"
62 "-shared -Wl,--compress-debug-sections=zlib"
63 "-fPIC -g -Wa,--compress-debug-sections=zlib"
64 {foo.c} {} "libzlibfoo.so"}
65 {"Build libgnufoo.so with zlib-gnu compressed debug sections"
66 "-shared -Wl,--compress-debug-sections=zlib-gnu"
67 "-fPIC -g -Wa,--compress-debug-sections=zlib-gnu"
68 {foo.c} {} "libgnufoo.so"}
69 {"Build libgabifoo.so with zlib-gabi compressed debug sections"
70 "-shared -Wl,--compress-debug-sections=zlib-gabi"
71 "-fPIC -g -Wa,--compress-debug-sections=zlib-gabi"
72 {foo.c} {} "libgabifoo.so"}
73 {"Build zlibbegin.o with zlib compressed debug sections"
74 "-r -nostdlib -Wl,--compress-debug-sections=zlib"
75 "-g -Wa,--compress-debug-sections=zlib"
76 {begin.c} {} "zlibbegin.o"}
77 {"Build gnubegin.o with zlib-gnu compressed debug sections"
78 "-r -nostdlib -Wl,--compress-debug-sections=zlib-gnu"
79 "-g -Wa,--compress-debug-sections=zlib-gnu"
80 {begin.c} {} "gnubegin.o"}
81 {"Build gabiend.o with zlib-gabi compressed debug sections"
82 "-r -nostdlib -Wl,--compress-debug-sections=zlib-gabi"
83 "-g -Wa,--compress-debug-sections=zlib-gnu"
84 {end.c} {} "gabiend.o"}
85 }
86
87 set run_tests {
88 {"Run normal with libfoo.so with compressed debug sections"
89 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" ""
90 {main.c} "normal" "normal.out" "-Wa,--compress-debug-sections"}
91 {"Run normal with libfoo.so with compressed debug sections with zlib-gabi"
92 "tmpdir/begin.o tmpdir/libfoozlib.so tmpdir/end.o" ""
93 {main.c} "normal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
94 {"Run zlibnormal with libzlibfoo.so with zlib compressed debug sections"
95 "tmpdir/begin.o tmpdir/libzlibfoo.so tmpdir/end.o --compress-debug-sections=zlib" ""
96 {main.c} "zlibnormal" "normal.out" "-Wa,--compress-debug-sections=zlib"}
97 {"Run gnunormal with libgnufoo.so with zlib-gnu compressed debug sections"
98 "tmpdir/gnubegin.o tmpdir/libgnufoo.so tmpdir/end.o --compress-debug-sections=zlib-gnu" ""
99 {main.c} "gnunormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gnu"}
100 {"Run gabinormal with libgabifoo.so with zlib-gabi compressed debug sections"
101 "tmpdir/zlibbegin.o tmpdir/libgabifoo.so tmpdir/gabiend.o --compress-debug-sections=zlib-gabi" ""
102 {main.c} "gabinormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
103 }
104
105 run_cc_link_tests $build_tests
106 run_ld_link_exec_tests [] $run_tests
107
108 set test_name "Link with zlib-gabi compressed debug input"
109 send_log "cmp tmpdir/libfoo.so tmpdir/libfoozlib.so\n"
110 if { [catch {exec cmp tmpdir/libfoo.so tmpdir/libfoozlib.so}] } then {
111 send_log "tmpdir/libfoo.so tmpdir/libfoozlib.so differ.\n"
112 fail "$test_name"
113 } else {
114 pass "$test_name"
115 }
116
117 global READELF
118
119 set test_name "Link -r with zlib compressed debug output"
120 set test zlibbegin
121 send_log "$READELF -S -W tmpdir/$test.o > tmpdir/$test.out\n"
122 set got [remote_exec host "$READELF -S -W tmpdir/$test.o" "" "/dev/null" "tmpdir/$test.out"]
123 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
124 send_log "$got\n"
125 unresolved "$test_name"
126 }
127 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
128 fail "$test_name"
129 } else {
130 pass "$test_name"
131 }
132
133 set test_name "Link -r with zlib-gnu compressed debug output"
134 set test gnubegin
135 send_log "$READELF -S -W tmpdir/$test.o > tmpdir/$test.out\n"
136 set got [remote_exec host "$READELF -S -W tmpdir/$test.o" "" "/dev/null" "tmpdir/$test.out"]
137 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
138 send_log "$got\n"
139 unresolved "$test_name"
140 }
141 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
142 fail "$test_name"
143 } else {
144 pass "$test_name"
145 }
146
147 set test_name "Link -r with zlib-gabi compressed debug output"
148 set test gabiend
149 send_log "$READELF -t -W tmpdir/$test.o > tmpdir/$test.out\n"
150 set got [remote_exec host "$READELF -t -W tmpdir/$test.o" "" "/dev/null" "tmpdir/$test.out"]
151 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
152 send_log "$got\n"
153 unresolved "$test_name"
154 }
155 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rt] } then {
156 fail "$test_name"
157 } else {
158 pass "$test_name"
159 }
160
161 set test_name "Link with zlib compressed debug output"
162 set test normal
163 send_log "$READELF -w tmpdir/$test > tmpdir/$test.out\n"
164 set got [remote_exec host "$READELF -w tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
165 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
166 send_log "$got\n"
167 unresolved "$test_name"
168 }
169
170 set test_name "Link with zlib compressed debug output"
171 set test zlibnormal
172 send_log "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out\n"
173 set got [remote_exec host "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\"" "" "/dev/null" "tmpdir/$test.out"]
174 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
175 send_log "$got\n"
176 unresolved "$test_name"
177 }
178 if { [catch {exec cmp tmpdir/normal.out tmpdir/$test.out}] } then {
179 send_log "tmpdir/normal.out tmpdir/$test.out differ.\n"
180 fail "$test_name"
181 } else {
182 pass "$test_name"
183 }
184 send_log "$READELF -S -W tmpdir/$test' > tmpdir/$test.out\n"
185 set got [remote_exec host "$READELF -S -W tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
186 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
187 send_log "$got\n"
188 unresolved "$test_name"
189 }
190 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
191 fail "$test_name"
192 } else {
193 pass "$test_name"
194 }
195
196 set test_name "Link with zlib-gnu compressed debug output"
197 set test gnunormal
198 send_log "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out\n"
199 set got [remote_exec host "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\"" "" "/dev/null" "tmpdir/$test.out"]
200 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
201 send_log "$got\n"
202 unresolved "$test_name"
203 }
204 if { [catch {exec cmp tmpdir/normal.out tmpdir/$test.out}] } then {
205 send_log "tmpdir/normal.out tmpdir/$test.out differ.\n"
206 fail "$test_name"
207 } else {
208 pass "$test_name"
209 }
210 send_log "$READELF -S -W tmpdir/$test' > tmpdir/$test.out\n"
211 set got [remote_exec host "$READELF -S -W tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
212 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
213 send_log "$got\n"
214 unresolved "$test_name"
215 }
216 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
217 fail "$test_name"
218 } else {
219 pass "$test_name"
220 }
221
222 set test gabinormal
223 set test_name "Link with zlib-gabi compressed debug output"
224 send_log "$READELF -w tmpdir/$test > tmpdir/$test.out\n"
225 set got [remote_exec host "$READELF -w tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
226 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
227 send_log "$got\n"
228 unresolved "$test_name"
229 }
230 if { [catch {exec cmp tmpdir/normal.out tmpdir/$test.out}] } then {
231 send_log "tmpdir/normal.out tmpdir/$test.out differ.\n"
232 fail "$test_name"
233 } else {
234 pass "$test_name"
235 }
236 send_log "$READELF -t -W tmpdir/$test > tmpdir/$test.out\n"
237 set got [remote_exec host "$READELF -t -W tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
238 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
239 send_log "$got\n"
240 unresolved "$test_name"
241 }
242 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rt] } then {
243 fail "$test_name"
244 } else {
245 pass "$test_name"
246 }