1 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
17 # Test compressed .debug section.
19 if { [is_remote host] || ![is_elf_format] } then {
23 set testfile tmpdir/dw2-1
24 set compressedfile tmpdir/dw2-1-compressed
25 set copyfile tmpdir/dw2-copy
26 set compressedfile2 tmpdir/dw2-2-compressed
27 set libfile tmpdir/libdw2
28 set compressedcopyfile tmpdir/dw2-copy-compressed
29 set testfile3 tmpdir/dw2-3
30 set compressedfile3 tmpdir/dw2-3-compressed
32 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${testfile}.o --nocompress-debug-sections] } then {
33 unsupported "compressed debug sections"
37 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}.o --compress-debug-sections] } then {
38 unsupported "compressed debug sections"
42 set got [remote_exec host "cmp ${testfile}.o ${compressedfile}.o"]
43 # Use it to set up xfail.
44 set exec_output [lindex $got 1]
45 if [string match "" $exec_output] then {
46 set compression_used ""
48 set compression_used "yes"
51 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}.o --compress-debug-sections] } then {
52 unsupported "compressed debug sections"
56 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${testfile3}.o --nocompress-debug-sections] } then {
57 unsupported "compressed debug sections"
61 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}.o --compress-debug-sections] } then {
62 unsupported "compressed debug sections"
66 remote_file host delete ${libfile}.a
67 set got [binutils_run $AR "rc ${libfile}.a ${compressedfile}.o ${compressedfile2}.o ${compressedfile3}.o"]
68 if ![string match "" $got] then {
69 fail "compressed debug sections"
73 set testname "objcopy compress debug sections"
74 set got [binutils_run $OBJCOPY "--compress-debug-sections ${testfile}.o ${copyfile}.o"]
75 if ![string match "" $got] then {
76 fail "objcopy ($testname)"
78 send_log "cmp ${compressedfile}.o ${copyfile}.o\n"
79 verbose "cmp ${compressedfile}.o ${copyfile}.o"
80 set src1 ${compressedfile}.o
81 set src2 ${copyfile}.o
82 set status [remote_exec build cmp "${src1} ${src2}"]
83 set exec_output [lindex $status 1]
84 set exec_output [prune_warnings $exec_output]
86 if [string match "" $exec_output] then {
87 pass "objcopy ($testname)"
89 send_log "$exec_output\n"
90 verbose "$exec_output" 1
91 fail "objcopy ($testname)"
95 set testname "objcopy decompress compressed debug sections"
96 set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile}.o ${copyfile}.o"]
97 if ![string match "" $got] then {
98 fail "objcopy ($testname)"
100 send_log "cmp ${testfile}.o ${copyfile}.o\n"
101 verbose "cmp ${testfile}.o ${copyfile}.o"
102 set src1 ${testfile}.o
103 set src2 ${copyfile}.o
104 set status [remote_exec build cmp "${src1} ${src2}"]
105 set exec_output [lindex $status 1]
106 set exec_output [prune_warnings $exec_output]
108 if [string match "" $exec_output] then {
109 pass "objcopy ($testname)"
111 send_log "$exec_output\n"
112 verbose "$exec_output" 1
113 fail "objcopy ($testname)"
117 set testname "objcopy decompress debug sections in archive"
118 set got [binutils_run $OBJCOPY "--decompress-debug-sections ${libfile}.a ${copyfile}.a"]
119 if ![string match "" $got] then {
120 fail "objcopy ($testname)"
122 set got [remote_exec host "$READELF -S --wide ${copyfile}.a" "" "/dev/null" "tmpdir/libdw2.out"]
124 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
125 fail "$testname (reason: unexpected output)"
130 if { [regexp_diff tmpdir/libdw2.out $srcdir/$subdir/libdw2.out] } then {
137 # Xfail this test if there are no compressed sections.
138 setup_xfail "$compression_used$target_triplet"
139 set testname "objcopy compress debug sections in archive"
140 set got [binutils_run $OBJCOPY "--compress-debug-sections ${copyfile}.a ${compressedcopyfile}.a"]
141 if ![string match "" $got] then {
142 fail "objcopy ($testname)"
144 set got [remote_exec host "$OBJDUMP -s -j .zdebug_line ${compressedcopyfile}.a" "" "/dev/null" "tmpdir/libdw2-compressed.out"]
146 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
147 fail "$testname (reason: unexpected output)"
152 setup_xfail "$compression_used$target_triplet"
153 if { [regexp_diff tmpdir/libdw2-compressed.out $srcdir/$subdir/libdw2-compressed.out] } then {
160 set testname "objdump compress debug sections"
161 set got [remote_exec host "$OBJDUMP -W ${compressedfile}.o" "" "/dev/null" "objdump.out"]
162 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
166 if { [regexp_diff objdump.out $srcdir/$subdir/dw2-1.W] } then {
172 set testname "objdump compress debug sections 3"
173 set got [remote_exec host "$OBJDUMP -W ${compressedfile3}.o" "" "/dev/null" "objdump.out"]
174 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
178 if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3.W] } then {
184 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-empty.S ${testfile}empty.o --nocompress-debug-sections] } then {
185 unsupported "compressed debug sections"
189 set testname "objcopy compress empty debug sections"
190 set got [binutils_run $OBJCOPY "--compress-debug-sections ${testfile}empty.o ${copyfile}empty.o"]
191 if ![string match "" $got] then {
192 fail "objcopy ($testname)"
194 send_log "cmp ${testfile}empty.o ${copyfile}empty.o\n"
195 verbose "cmp ${testfile}empty.o ${copyfile}empty.o"
196 set src1 ${testfile}empty.o
197 set src2 ${copyfile}empty.o
198 set status [remote_exec build cmp "${src1} ${src2}"]
199 set exec_output [lindex $status 1]
200 set exec_output [prune_warnings $exec_output]
202 if [string match "" $exec_output] then {
203 pass "objcopy ($testname)"
205 send_log "$exec_output\n"
206 verbose "$exec_output" 1
207 fail "objcopy ($testname)"
211 if ![is_remote host] {
212 set tempfile tmpdir/debug_str.o
213 set copyfile tmpdir/debug_str.copy
215 set tempfile [remote_download host tmpdir/debug_str.o]
216 set copyfile debug_str.copy
219 run_dump_test "debug_str"
221 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gabi.o --compress-debug-sections=zlib-gabi] } then {
222 fail "compressed debug sections with zlib-gabi"
226 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gnu.o --compress-debug-sections=zlib-gnu] } then {
227 fail "compressed debug sections with zlib-gnu"
231 set src1 ${compressedfile}gnu.o
232 set src2 ${compressedfile}.o
233 set status [remote_exec build cmp "${src1} ${src2}"]
234 set exec_output [lindex $status 1]
235 set exec_output [prune_warnings $exec_output]
236 if ![string match "" $exec_output] then {
237 fail "compressed debug sections with zlib-gnu"
241 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}gabi.o --compress-debug-sections=zlib-gabi] } then {
242 fail "compressed debug sections with zlib-gabi"
246 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}gnu.o --compress-debug-sections=zlib-gnu] } then {
247 fail "compressed debug sections with zlib-gnu"
251 set src1 ${compressedfile2}gnu.o
252 set src2 ${compressedfile2}.o
253 set status [remote_exec build cmp "${src1} ${src2}"]
254 set exec_output [lindex $status 1]
255 set exec_output [prune_warnings $exec_output]
256 if ![string match "" $exec_output] then {
257 fail "compressed debug sections with zlib-gnu"
261 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}gabi.o --compress-debug-sections=zlib-gabi] } then {
262 fail "compressed debug sections with zlib-gabi"
266 set testname "readelf -t zlib-gabi compress debug sections"
267 set got [remote_exec host "$READELF -t --wide ${compressedfile3}gabi.o" "" "/dev/null" "tmpdir/dw2-3.rt"]
268 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
269 fail "$testname (reason: unexpected output)"
272 if { [regexp_diff tmpdir/dw2-3.rt $srcdir/$subdir/dw2-3.rt] } then {
278 set testname "readelf -S zlib-gabi compress debug sections"
279 set got [remote_exec host "$READELF -S --wide ${compressedfile3}gabi.o" "" "/dev/null" "tmpdir/dw2-3.rS"]
280 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
281 fail "$testname (reason: unexpected output)"
284 if { [regexp_diff tmpdir/dw2-3.rS $srcdir/$subdir/dw2-3.rS] } then {
290 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}gnu.o --compress-debug-sections=zlib-gnu] } then {
291 fail "compressed debug sections with zlib-gnu"
295 set src1 ${compressedfile3}gnu.o
296 set src2 ${compressedfile3}.o
297 set status [remote_exec build cmp "${src1} ${src2}"]
298 set exec_output [lindex $status 1]
299 set exec_output [prune_warnings $exec_output]
300 if ![string match "" $exec_output] then {
301 fail "compressed debug sections with zlib-gnu"
305 remote_file host delete ${libfile}gabi.a
306 set got [binutils_run $AR "rc ${libfile}gabi.a ${compressedfile}gabi.o ${compressedfile2}gabi.o ${compressedfile3}gabi.o"]
307 if ![string match "" $got] then {
308 fail "compressed debug sections"
312 set testname "objcopy compress debug sections with zlib-gabi"
313 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${testfile}.o ${copyfile}gabi.o"]
314 if ![string match "" $got] then {
315 fail "objcopy ($testname)"
318 send_log "cmp ${compressedfile}gabi.o ${copyfile}gabi.o\n"
319 verbose "cmp ${compressedfile}gabi.o ${copyfile}gabi.o"
320 set src1 ${compressedfile}gabi.o
321 set src2 ${copyfile}gabi.o
322 set status [remote_exec build cmp "${src1} ${src2}"]
323 set exec_output [lindex $status 1]
324 set exec_output [prune_warnings $exec_output]
325 if ![string match "" $exec_output] then {
326 send_log "$exec_output\n"
327 verbose "$exec_output" 1
328 fail "objcopy ($testname)"
330 pass "objcopy ($testname)"
333 set testname "objcopy decompress compressed debug sections with zlib-gabi"
334 set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile}gabi.o ${copyfile}gabi.o"]
335 if ![string match "" $got] then {
336 fail "objcopy ($testname)"
339 send_log "cmp ${testfile}.o ${copyfile}gabi.o\n"
340 verbose "cmp ${testfile}.o ${copyfile}gabi.o"
341 set src1 ${testfile}.o
342 set src2 ${copyfile}gabi.o
343 set status [remote_exec build cmp "${src1} ${src2}"]
344 set exec_output [lindex $status 1]
345 set exec_output [prune_warnings $exec_output]
346 if ![string match "" $exec_output] then {
347 send_log "$exec_output\n"
348 verbose "$exec_output" 1
349 fail "objcopy ($testname)"
351 pass "objcopy ($testname)"
354 set testname "objcopy zlib-gnu compress debug sections with zlib-gabi"
355 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${compressedfile}.o ${copyfile}gabi.o"]
356 if ![string match "" $got] then {
357 fail "objcopy ($testname)"
360 send_log "cmp ${compressedfile}gabi.o ${copyfile}gabi.o\n"
361 verbose "cmp ${compressedfile}gabi.o ${copyfile}gabi.o"
362 set src1 ${compressedfile}gabi.o
363 set src2 ${copyfile}gabi.o
364 set status [remote_exec build cmp "${src1} ${src2}"]
365 set exec_output [lindex $status 1]
366 set exec_output [prune_warnings $exec_output]
367 if ![string match "" $exec_output] then {
368 send_log "$exec_output\n"
369 verbose "$exec_output" 1
370 fail "objcopy ($testname)"
372 pass "objcopy ($testname)"
375 set testname "objcopy zlib-gabi compress debug sections with zlib-gnu"
376 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${compressedfile}gabi.o ${copyfile}gnu.o"]
377 if ![string match "" $got] then {
378 fail "objcopy ($testname)"
381 send_log "cmp ${compressedfile}gnu.o ${copyfile}gnu.o\n"
382 verbose "cmp ${compressedfile}gnu.o ${copyfile}gnu.o"
383 set src1 ${compressedfile}gnu.o
384 set src2 ${copyfile}gnu.o
385 set status [remote_exec build cmp "${src1} ${src2}"]
386 set exec_output [lindex $status 1]
387 set exec_output [prune_warnings $exec_output]
388 if ![string match "" $exec_output] then {
389 send_log "$exec_output\n"
390 verbose "$exec_output" 1
391 fail "objcopy ($testname)"
393 pass "objcopy ($testname)"
396 set testname "objcopy compress debug sections 3 with zlib-gabi"
397 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${testfile3}.o ${copyfile}gabi.o"]
398 if ![string match "" $got] then {
399 fail "objcopy ($testname)"
402 send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
403 verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
404 set src1 ${compressedfile3}gabi.o
405 set src2 ${copyfile}gabi.o
406 set status [remote_exec build cmp "${src1} ${src2}"]
407 set exec_output [lindex $status 1]
408 set exec_output [prune_warnings $exec_output]
409 if ![string match "" $exec_output] then {
410 send_log "$exec_output\n"
411 verbose "$exec_output" 1
412 fail "objcopy ($testname)"
414 pass "objcopy ($testname)"
417 set testname "objcopy decompress compressed debug sections 3 with zlib-gabi"
418 set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile3}gabi.o ${copyfile}gabi.o"]
419 if ![string match "" $got] then {
420 fail "objcopy ($testname)"
423 send_log "cmp ${testfile3}.o ${copyfile}gabi.o\n"
424 verbose "cmp ${testfile3}.o ${copyfile}gabi.o"
425 set src1 ${testfile3}.o
426 set src2 ${copyfile}gabi.o
427 set status [remote_exec build cmp "${src1} ${src2}"]
428 set exec_output [lindex $status 1]
429 set exec_output [prune_warnings $exec_output]
430 if ![string match "" $exec_output] then {
431 send_log "$exec_output\n"
432 verbose "$exec_output" 1
433 fail "objcopy ($testname)"
435 pass "objcopy ($testname)"
438 set testname "objcopy zlib-gnu compress debug sections 3 with zlib-gabi"
439 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${compressedfile3}.o ${copyfile}gabi.o"]
440 if ![string match "" $got] then {
441 fail "objcopy ($testname)"
444 send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
445 verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
446 set src1 ${compressedfile3}gabi.o
447 set src2 ${copyfile}gabi.o
448 set status [remote_exec build cmp "${src1} ${src2}"]
449 set exec_output [lindex $status 1]
450 set exec_output [prune_warnings $exec_output]
451 if ![string match "" $exec_output] then {
452 send_log "$exec_output\n"
453 verbose "$exec_output" 1
454 fail "objcopy ($testname)"
456 pass "objcopy ($testname)"
459 set testname "objcopy zlib-gabi compress debug sections 3 with zlib-gnu"
460 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${compressedfile3}gabi.o ${copyfile}gnu.o"]
461 if ![string match "" $got] then {
462 fail "objcopy ($testname)"
465 send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
466 verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
467 set src1 ${compressedfile3}gnu.o
468 set src2 ${copyfile}gnu.o
469 set status [remote_exec build cmp "${src1} ${src2}"]
470 set exec_output [lindex $status 1]
471 set exec_output [prune_warnings $exec_output]
472 if ![string match "" $exec_output] then {
473 send_log "$exec_output\n"
474 verbose "$exec_output" 1
475 fail "objcopy ($testname)"
477 pass "objcopy ($testname)"
480 set testname "objcopy zlib-gnu compress debug sections 3"
481 set got [binutils_run $OBJCOPY "${compressedfile3}gnu.o ${copyfile}gnu.o"]
482 if ![string match "" $got] then {
483 fail "objcopy ($testname)"
486 send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
487 verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
488 set src1 ${compressedfile3}gnu.o
489 set src2 ${copyfile}gnu.o
490 set status [remote_exec build cmp "${src1} ${src2}"]
491 set exec_output [lindex $status 1]
492 set exec_output [prune_warnings $exec_output]
493 if ![string match "" $exec_output] then {
494 send_log "$exec_output\n"
495 verbose "$exec_output" 1
496 fail "objcopy ($testname)"
498 pass "objcopy ($testname)"
501 set testname "objcopy zlib-gnu compress debug sections 3"
502 set got [binutils_run $OBJCOPY "${compressedfile3}gnu.o ${copyfile}gnu.o"]
503 if ![string match "" $got] then {
504 fail "objcopy ($testname)"
507 send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
508 verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
509 set src1 ${compressedfile3}gnu.o
510 set src2 ${copyfile}gnu.o
511 set status [remote_exec build cmp "${src1} ${src2}"]
512 set exec_output [lindex $status 1]
513 set exec_output [prune_warnings $exec_output]
514 if ![string match "" $exec_output] then {
515 send_log "$exec_output\n"
516 verbose "$exec_output" 1
517 fail "objcopy ($testname)"
519 pass "objcopy ($testname)"
522 set testname "objcopy decompress debug sections in archive with zlib-gabi"
523 set got [binutils_run $OBJCOPY "--decompress-debug-sections ${libfile}gabi.a ${copyfile}gabi.a"]
524 if ![string match "" $got] then {
525 fail "objcopy ($testname)"
527 set got [remote_exec host "$READELF -S --wide ${copyfile}gabi.a" "" "/dev/null" "tmpdir/libdw2.out"]
529 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
530 fail "$testname (reason: unexpected output)"
535 if { [regexp_diff tmpdir/libdw2.out $srcdir/$subdir/libdw2.out] } then {
542 set testname "objcopy compress debug sections in archive with zlib-gabi"
543 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${copyfile}gabi.a ${compressedcopyfile}gabi.a"]
544 if ![string match "" $got] then {
545 fail "objcopy ($testname)"
547 set got [remote_exec host "$OBJDUMP -W ${compressedcopyfile}gabi.a" "" "/dev/null" "tmpdir/libdw2-compressedgabi.out"]
549 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
550 fail "$testname (reason: unexpected output)"
555 if { [regexp_diff tmpdir/libdw2-compressedgabi.out $srcdir/$subdir/libdw2-compressedgabi.out] } then {
562 set testname "objdump compress debug sections 3 with zlib-gabi"
563 set got [remote_exec host "$OBJDUMP -W ${compressedfile3}gabi.o" "" "/dev/null" "objdump.out"]
564 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
568 if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3gabi.W] } then {