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