3fb4bd794bdd9650fd6ee1dcfac89bf404504b2f
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / compress.exp
1 # Expect script for ELF compressed debug section tests.
2 # Copyright (C) 2010-2017 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 # Skip targets where -shared is not supported
29
30 if ![check_shared_lib_support] {
31 return
32 }
33
34 # Check if compiler works
35 if { [which $CC] == 0 } {
36 return
37 }
38
39 global as
40 if { ![ld_assemble $as "--compress-debug-sections $srcdir/$subdir/empty.s" tmpdir/empty.o ] } {
41 fail "linker compressed debug sections"
42 }
43
44 if { ![ld_assemble $as "--compress-debug-sections=zlib-gabi $srcdir/$subdir/empty.s" tmpdir/emptyzlib.o ] } {
45 fail "linker compressed debug sections"
46 }
47
48 set build_tests {
49 {"Build libfoo.so with compressed debug sections"
50 "-shared" "-fPIC -ggdb3 -Wa,--compress-debug-sections"
51 {foo.c} {} "libfoo.so"}
52 {"Build libbar.so with compressed debug sections"
53 "-shared -Wl,--compress-debug-sections=none"
54 "-fPIC -ggdb3 -Wa,--compress-debug-sections"
55 {begin.c end.c} {} "libbar.so"}
56 {"Build libfoozlib.so with compressed debug sections with zlib-gabi"
57 "-shared" "-fPIC -ggdb3 -Wa,--compress-debug-sections=zlib-gabi"
58 {foo.c} {} "libfoozlib.so"}
59 {"Build libbarzlib.so with compressed debug sections with zlib-gabi"
60 "-shared" "-fPIC -ggdb3 -Wa,--compress-debug-sections=zlib-gabi"
61 {begin.c end.c} {} "libbarzlib.so"}
62 {"Build libzlibfoo.so with zlib compressed debug sections"
63 "-shared -Wl,--compress-debug-sections=zlib"
64 "-fPIC -ggdb3 -Wa,--compress-debug-sections=zlib"
65 {foo.c} {} "libzlibfoo.so"}
66 {"Build libgnufoo.so with zlib-gnu compressed debug sections"
67 "-shared -Wl,--compress-debug-sections=zlib-gnu"
68 "-fPIC -ggdb3 -Wa,--compress-debug-sections=zlib-gnu"
69 {foo.c} {} "libgnufoo.so"}
70 {"Build libgabifoo.so with zlib-gabi compressed debug sections"
71 "-shared -Wl,--compress-debug-sections=zlib-gabi"
72 "-fPIC -ggdb3 -Wa,--compress-debug-sections=zlib-gabi"
73 {foo.c} {} "libgabifoo.so"}
74 {"Build zlibbegin.o with zlib compressed debug sections"
75 "-r -nostdlib -Wl,--compress-debug-sections=zlib"
76 "-ggdb3 -Wa,--compress-debug-sections=zlib"
77 {begin.c} {} "zlibbegin.o"}
78 {"Build gnubegin.o with zlib-gnu compressed debug sections"
79 "-r -nostdlib -Wl,--compress-debug-sections=zlib-gnu"
80 "-ggdb3 -Wa,--compress-debug-sections=zlib-gnu"
81 {begin.c} {} "gnubegin.o"}
82 {"Build gabiend.o with zlib-gabi compressed debug sections"
83 "-r -nostdlib -Wl,--compress-debug-sections=zlib-gabi"
84 "-ggdb3 -Wa,--compress-debug-sections=zlib-gnu"
85 {end.c} {} "gabiend.o"}
86 }
87
88 set run_tests {
89 {"Run normal with libfoo.so with compressed debug sections"
90 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" ""
91 {main.c} "normal" "normal.out" "-Wa,--compress-debug-sections"}
92 {"Run normal with libfoozlib.so with compressed debug sections with zlib-gabi"
93 "tmpdir/begin.o tmpdir/libfoozlib.so tmpdir/end.o" ""
94 {main.c} "normal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
95 {"Run zlibnormal with libzlibfoo.so with zlib compressed debug sections"
96 "tmpdir/begin.o tmpdir/libzlibfoo.so tmpdir/end.o -Wl,--compress-debug-sections=zlib" ""
97 {main.c} "zlibnormal" "normal.out" "-Wa,--compress-debug-sections=zlib"}
98 {"Run zlibnormal with libfoozlib.so with zlib compressed debug sections"
99 "tmpdir/begin.o tmpdir/libfoozlib.so tmpdir/end.o -Wl,--compress-debug-sections=zlib" ""
100 {main.c} "zlibnormal" "normal.out" "-Wa,--compress-debug-sections=zlib"}
101 {"Run gnunormal with libgnufoo.so with zlib-gnu compressed debug sections"
102 "tmpdir/gnubegin.o tmpdir/libgnufoo.so tmpdir/end.o -Wl,--compress-debug-sections=zlib-gnu" ""
103 {main.c} "gnunormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gnu"}
104 {"Run gnunormal with libfoozlib.so with zlib-gnu compressed debug sections"
105 "tmpdir/gnubegin.o tmpdir/libfoozlib.so tmpdir/end.o -Wl,--compress-debug-sections=zlib-gnu" ""
106 {main.c} "gnunormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gnu"}
107 {"Run gabinormal with libgabifoo.so with zlib-gabi compressed debug sections"
108 "tmpdir/zlibbegin.o tmpdir/libgabifoo.so tmpdir/gabiend.o -Wl,--compress-debug-sections=zlib-gabi" ""
109 {main.c} "gabinormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
110 {"Run gabinormal with libfoozlib.so with zlib-gabi compressed debug sections"
111 "tmpdir/zlibbegin.o tmpdir/libfoozlib.so tmpdir/gabiend.o -Wl,--compress-debug-sections=zlib-gabi" ""
112 {main.c} "gabinormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
113 }
114
115 run_cc_link_tests $build_tests
116 run_ld_link_exec_tests $run_tests
117
118 set test_name "Link with zlib-gabi compressed debug input"
119 send_log "cmp tmpdir/libfoo.so tmpdir/libfoozlib.so\n"
120 if { [catch {exec cmp tmpdir/libfoo.so tmpdir/libfoozlib.so}] } then {
121 send_log "tmpdir/libfoo.so tmpdir/libfoozlib.so differ.\n"
122 fail "$test_name"
123 } else {
124 pass "$test_name"
125 }
126
127 global READELF
128
129 set test_name "Link -r with zlib compressed debug output"
130 set test zlibbegin
131 send_log "$READELF -S -W tmpdir/$test.o > tmpdir/$test.out\n"
132 set got [remote_exec host "$READELF -S -W tmpdir/$test.o" "" "/dev/null" "tmpdir/$test.out"]
133 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
134 send_log "$got\n"
135 unresolved "$test_name"
136 }
137 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
138 fail "$test_name"
139 } else {
140 pass "$test_name"
141 }
142
143 set test_name "Link -r with zlib-gnu compressed debug output"
144 set test gnubegin
145 send_log "$READELF -S -W tmpdir/$test.o > tmpdir/$test.out\n"
146 set got [remote_exec host "$READELF -S -W tmpdir/$test.o" "" "/dev/null" "tmpdir/$test.out"]
147 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
148 send_log "$got\n"
149 unresolved "$test_name"
150 }
151 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
152 fail "$test_name"
153 } else {
154 pass "$test_name"
155 }
156
157 set test_name "Link -r with zlib-gabi compressed debug output"
158 set test gabiend
159 send_log "$READELF -t -W tmpdir/$test.o > tmpdir/$test.out\n"
160 set got [remote_exec host "$READELF -t -W tmpdir/$test.o" "" "/dev/null" "tmpdir/$test.out"]
161 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
162 send_log "$got\n"
163 unresolved "$test_name"
164 }
165 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rt] } then {
166 fail "$test_name"
167 } else {
168 pass "$test_name"
169 }
170
171 set test_name "Link with zlib compressed debug output"
172 set test normal
173 send_log "$READELF -w tmpdir/$test > tmpdir/$test.out\n"
174 set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test > tmpdir/$test.out"]] "" "/dev/null"]
175 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
176 send_log "$got\n"
177 unresolved "$test_name"
178 }
179
180 set test_name "Link with zlib compressed debug output"
181 set test zlibnormal
182 send_log "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out\n"
183 set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out"]] "" "/dev/null"]
184 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
185 send_log "$got\n"
186 unresolved "$test_name"
187 }
188 if { [catch {exec cmp tmpdir/normal.out tmpdir/$test.out}] } then {
189 send_log "tmpdir/normal.out tmpdir/$test.out differ.\n"
190 fail "$test_name"
191 } else {
192 pass "$test_name"
193 }
194 send_log "$READELF -S -W tmpdir/$test' > tmpdir/$test.out\n"
195 set got [remote_exec host "$READELF -S -W tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
196 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
197 send_log "$got\n"
198 unresolved "$test_name"
199 }
200 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
201 fail "$test_name"
202 } else {
203 pass "$test_name"
204 }
205
206 set test_name "Link with zlib-gnu compressed debug output"
207 set test gnunormal
208 send_log "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out\n"
209 set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out"]] "" "/dev/null"]
210 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
211 send_log "$got\n"
212 unresolved "$test_name"
213 }
214 if { [catch {exec cmp tmpdir/normal.out tmpdir/$test.out}] } then {
215 send_log "tmpdir/normal.out tmpdir/$test.out differ.\n"
216 fail "$test_name"
217 } else {
218 pass "$test_name"
219 }
220 send_log "$READELF -S -W tmpdir/$test' > tmpdir/$test.out\n"
221 set got [remote_exec host "$READELF -S -W tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
222 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
223 send_log "$got\n"
224 unresolved "$test_name"
225 }
226 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
227 fail "$test_name"
228 } else {
229 pass "$test_name"
230 }
231
232 set test gabinormal
233 set test_name "Link with zlib-gabi compressed debug output"
234 send_log "$READELF -w tmpdir/$test > tmpdir/$test.out\n"
235 set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test > tmpdir/$test.out"]] "" "/dev/null"]
236 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
237 send_log "$got\n"
238 unresolved "$test_name"
239 }
240 if { [catch {exec cmp tmpdir/normal.out tmpdir/$test.out}] } then {
241 send_log "tmpdir/normal.out tmpdir/$test.out differ.\n"
242 fail "$test_name"
243 } else {
244 pass "$test_name"
245 }
246 send_log "$READELF -t -W tmpdir/$test > tmpdir/$test.out\n"
247 set got [remote_exec host "$READELF -t -W tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
248 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
249 send_log "$got\n"
250 unresolved "$test_name"
251 }
252 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rt] } then {
253 fail "$test_name"
254 } else {
255 pass "$test_name"
256 }
This page took 0.03551 seconds and 3 git commands to generate.