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