Commit | Line | Data |
---|---|---|
4a114e3e | 1 | # Expect script for ELF compressed debug section tests. |
2571583a | 2 | # Copyright (C) 2010-2017 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 | ||
24 | if ![is_elf_format] { | |
25 | return | |
26 | } | |
27 | ||
47523653 AM |
28 | # Skip targets where -shared is not supported |
29 | ||
30 | if ![check_shared_lib_support] { | |
31 | return | |
32 | } | |
33 | ||
4a114e3e L |
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 ] } { | |
dae148f3 | 41 | fail "linker compressed debug sections" |
4a114e3e L |
42 | } |
43 | ||
151411f8 L |
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 | ||
4a114e3e L |
48 | set 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 | ||
88 | set 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 | ||
115 | run_cc_link_tests $build_tests | |
982c6f26 | 116 | run_ld_link_exec_tests $run_tests |
151411f8 L |
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 | } | |
0ce398f1 L |
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" | |
65f90e82 | 174 | set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test > tmpdir/$test.out"]] "" "/dev/null"] |
0ce398f1 L |
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" | |
65f90e82 | 183 | set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out"]] "" "/dev/null"] |
0ce398f1 L |
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" | |
65f90e82 | 209 | set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out"]] "" "/dev/null"] |
0ce398f1 L |
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" | |
65f90e82 | 235 | set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test > tmpdir/$test.out"]] "" "/dev/null"] |
0ce398f1 L |
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 | } |