Update ld-elf/orphan-8.map to support 32-bit targets
[deliverable/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 -ggdb3 -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 -ggdb3 -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 -ggdb3 -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 -ggdb3 -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 -ggdb3 -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 -ggdb3 -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 -ggdb3 -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 "-ggdb3 -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 "-ggdb3 -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 "-ggdb3 -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 libfoozlib.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 zlibnormal with libfoozlib.so with zlib compressed debug sections"
98 "tmpdir/begin.o tmpdir/libfoozlib.so tmpdir/end.o --compress-debug-sections=zlib" ""
99 {main.c} "zlibnormal" "normal.out" "-Wa,--compress-debug-sections=zlib"}
100 {"Run gnunormal with libgnufoo.so with zlib-gnu compressed debug sections"
101 "tmpdir/gnubegin.o tmpdir/libgnufoo.so tmpdir/end.o --compress-debug-sections=zlib-gnu" ""
102 {main.c} "gnunormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gnu"}
103 {"Run gnunormal with libfoozlib.so with zlib-gnu compressed debug sections"
104 "tmpdir/gnubegin.o tmpdir/libfoozlib.so tmpdir/end.o --compress-debug-sections=zlib-gnu" ""
105 {main.c} "gnunormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gnu"}
106 {"Run gabinormal with libgabifoo.so with zlib-gabi compressed debug sections"
107 "tmpdir/zlibbegin.o tmpdir/libgabifoo.so tmpdir/gabiend.o --compress-debug-sections=zlib-gabi" ""
108 {main.c} "gabinormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
109 {"Run gabinormal with libfoozlib.so with zlib-gabi compressed debug sections"
110 "tmpdir/zlibbegin.o tmpdir/libfoozlib.so tmpdir/gabiend.o --compress-debug-sections=zlib-gabi" ""
111 {main.c} "gabinormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
112 }
113
114 run_cc_link_tests $build_tests
115 run_ld_link_exec_tests [] $run_tests
116
117 set test_name "Link with zlib-gabi compressed debug input"
118 send_log "cmp tmpdir/libfoo.so tmpdir/libfoozlib.so\n"
119 if { [catch {exec cmp tmpdir/libfoo.so tmpdir/libfoozlib.so}] } then {
120 send_log "tmpdir/libfoo.so tmpdir/libfoozlib.so differ.\n"
121 fail "$test_name"
122 } else {
123 pass "$test_name"
124 }
125
126 global READELF
127
128 set test_name "Link -r with zlib compressed debug output"
129 set test zlibbegin
130 send_log "$READELF -S -W tmpdir/$test.o > tmpdir/$test.out\n"
131 set got [remote_exec host "$READELF -S -W tmpdir/$test.o" "" "/dev/null" "tmpdir/$test.out"]
132 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
133 send_log "$got\n"
134 unresolved "$test_name"
135 }
136 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
137 fail "$test_name"
138 } else {
139 pass "$test_name"
140 }
141
142 set test_name "Link -r with zlib-gnu compressed debug output"
143 set test gnubegin
144 send_log "$READELF -S -W tmpdir/$test.o > tmpdir/$test.out\n"
145 set got [remote_exec host "$READELF -S -W tmpdir/$test.o" "" "/dev/null" "tmpdir/$test.out"]
146 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
147 send_log "$got\n"
148 unresolved "$test_name"
149 }
150 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
151 fail "$test_name"
152 } else {
153 pass "$test_name"
154 }
155
156 set test_name "Link -r with zlib-gabi compressed debug output"
157 set test gabiend
158 send_log "$READELF -t -W tmpdir/$test.o > tmpdir/$test.out\n"
159 set got [remote_exec host "$READELF -t -W tmpdir/$test.o" "" "/dev/null" "tmpdir/$test.out"]
160 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
161 send_log "$got\n"
162 unresolved "$test_name"
163 }
164 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rt] } then {
165 fail "$test_name"
166 } else {
167 pass "$test_name"
168 }
169
170 set test_name "Link with zlib compressed debug output"
171 set test normal
172 send_log "$READELF -w tmpdir/$test > tmpdir/$test.out\n"
173 set got [remote_exec host "$READELF -w tmpdir/$test" "" "/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
179 set test_name "Link with zlib compressed debug output"
180 set test zlibnormal
181 send_log "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out\n"
182 set got [remote_exec host "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\"" "" "/dev/null" "tmpdir/$test.out"]
183 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
184 send_log "$got\n"
185 unresolved "$test_name"
186 }
187 if { [catch {exec cmp tmpdir/normal.out tmpdir/$test.out}] } then {
188 send_log "tmpdir/normal.out tmpdir/$test.out differ.\n"
189 fail "$test_name"
190 } else {
191 pass "$test_name"
192 }
193 send_log "$READELF -S -W tmpdir/$test' > tmpdir/$test.out\n"
194 set got [remote_exec host "$READELF -S -W tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
195 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
196 send_log "$got\n"
197 unresolved "$test_name"
198 }
199 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
200 fail "$test_name"
201 } else {
202 pass "$test_name"
203 }
204
205 set test_name "Link with zlib-gnu compressed debug output"
206 set test gnunormal
207 send_log "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out\n"
208 set got [remote_exec host "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\"" "" "/dev/null" "tmpdir/$test.out"]
209 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
210 send_log "$got\n"
211 unresolved "$test_name"
212 }
213 if { [catch {exec cmp tmpdir/normal.out tmpdir/$test.out}] } then {
214 send_log "tmpdir/normal.out tmpdir/$test.out differ.\n"
215 fail "$test_name"
216 } else {
217 pass "$test_name"
218 }
219 send_log "$READELF -S -W tmpdir/$test' > tmpdir/$test.out\n"
220 set got [remote_exec host "$READELF -S -W tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
221 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
222 send_log "$got\n"
223 unresolved "$test_name"
224 }
225 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
226 fail "$test_name"
227 } else {
228 pass "$test_name"
229 }
230
231 set test gabinormal
232 set test_name "Link with zlib-gabi compressed debug output"
233 send_log "$READELF -w tmpdir/$test > tmpdir/$test.out\n"
234 set got [remote_exec host "$READELF -w tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
235 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
236 send_log "$got\n"
237 unresolved "$test_name"
238 }
239 if { [catch {exec cmp tmpdir/normal.out tmpdir/$test.out}] } then {
240 send_log "tmpdir/normal.out tmpdir/$test.out differ.\n"
241 fail "$test_name"
242 } else {
243 pass "$test_name"
244 }
245 send_log "$READELF -t -W tmpdir/$test > tmpdir/$test.out\n"
246 set got [remote_exec host "$READELF -t -W tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
247 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
248 send_log "$got\n"
249 unresolved "$test_name"
250 }
251 if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rt] } then {
252 fail "$test_name"
253 } else {
254 pass "$test_name"
255 }
This page took 0.035256 seconds and 4 git commands to generate.