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