]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - binutils/testsuite/binutils-all/compress.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / binutils / testsuite / binutils-all / compress.exp
1 # Copyright (C) 2010-2021 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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.
16
17 # Test compressed .debug section.
18
19 if { [is_remote host] || ![is_elf_format] } then {
20 return
21 }
22
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
31
32 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${testfile}.o --nocompress-debug-sections] } then {
33 unsupported "compressed debug sections"
34 return
35 }
36
37 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}.o --compress-debug-sections] } then {
38 unsupported "compressed debug sections"
39 return
40 }
41
42 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gnu.o --compress-debug-sections=zlib-gnu] } then {
43 unsupported "compressed debug sections with zlib-gnu"
44 return
45 }
46
47 set got [remote_exec host "cmp ${testfile}.o ${compressedfile}gnu.o"]
48 # Use it to set up xfail.
49 set exec_output [lindex $got 1]
50 if [string match "" $exec_output] then {
51 set compression_used ""
52 } else {
53 set compression_used "yes"
54 }
55
56 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}.o --compress-debug-sections] } then {
57 unsupported "compressed debug sections"
58 return
59 }
60
61 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${testfile3}.o --nocompress-debug-sections] } then {
62 unsupported "compressed debug sections"
63 return
64 }
65
66 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}.o --compress-debug-sections] } then {
67 unsupported "compressed debug sections"
68 return
69 }
70
71 remote_file host delete ${libfile}.a
72 set got [binutils_run $AR "rc ${libfile}.a ${compressedfile}.o ${compressedfile2}.o ${compressedfile3}.o"]
73 if ![string match "" $got] then {
74 fail "compressed debug sections"
75 return
76 }
77
78 set testname "objcopy compress debug sections"
79 set got [binutils_run $OBJCOPY "--compress-debug-sections ${testfile}.o ${copyfile}.o"]
80 if ![string match "" $got] then {
81 fail "objcopy ($testname)"
82 } else {
83 send_log "cmp ${compressedfile}.o ${copyfile}.o\n"
84 verbose "cmp ${compressedfile}.o ${copyfile}.o"
85 set src1 ${compressedfile}.o
86 set src2 ${copyfile}.o
87 set status [remote_exec build cmp "${src1} ${src2}"]
88 set exec_output [lindex $status 1]
89 set exec_output [prune_warnings $exec_output]
90
91 if [string match "" $exec_output] then {
92 pass "objcopy ($testname)"
93 } else {
94 send_log "$exec_output\n"
95 verbose "$exec_output" 1
96 fail "objcopy ($testname)"
97 }
98 }
99
100 set testname "objcopy decompress compressed debug sections"
101 set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile}.o ${copyfile}.o"]
102 if ![string match "" $got] then {
103 fail "objcopy ($testname)"
104 } else {
105 send_log "cmp ${testfile}.o ${copyfile}.o\n"
106 verbose "cmp ${testfile}.o ${copyfile}.o"
107 set src1 ${testfile}.o
108 set src2 ${copyfile}.o
109 set status [remote_exec build cmp "${src1} ${src2}"]
110 set exec_output [lindex $status 1]
111 set exec_output [prune_warnings $exec_output]
112
113 if [string match "" $exec_output] then {
114 pass "objcopy ($testname)"
115 } else {
116 send_log "$exec_output\n"
117 verbose "$exec_output" 1
118 fail "objcopy ($testname)"
119 }
120 }
121
122 set testname "objcopy decompress debug sections in archive"
123 set got [binutils_run $OBJCOPY "--decompress-debug-sections ${libfile}.a ${copyfile}.a"]
124 if ![string match "" $got] then {
125 fail "objcopy ($testname)"
126 } else {
127 set got [remote_exec host "$READELF -S --wide ${copyfile}.a" "" "/dev/null" "tmpdir/libdw2.out"]
128
129 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
130 fail "$testname (reason: unexpected output)"
131 send_log $got
132 send_log "\n"
133 }
134
135 if { [regexp_diff tmpdir/libdw2.out $srcdir/$subdir/libdw2.out] } then {
136 fail "$testname"
137 } else {
138 pass "$testname"
139 }
140 }
141
142 # Xfail this test if there are no compressed sections.
143 setup_xfail "$compression_used$target_triplet"
144 set testname "objcopy compress debug sections in archive with zlib-gnu"
145 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${copyfile}.a ${compressedcopyfile}.a"]
146 if ![string match "" $got] then {
147 fail "objcopy ($testname)"
148 } else {
149 set got [remote_exec host "$OBJDUMP -s -j .zdebug_line ${compressedcopyfile}.a" "" "/dev/null" "tmpdir/libdw2-compressed.out"]
150
151 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
152 fail "$testname (reason: unexpected output)"
153 send_log $got
154 send_log "\n"
155 }
156
157 setup_xfail "$compression_used$target_triplet"
158 if { [regexp_diff tmpdir/libdw2-compressed.out $srcdir/$subdir/libdw2-compressed.out] } then {
159 fail "$testname"
160 } else {
161 pass "$testname"
162 }
163 }
164
165 setup_xfail "nds32*-*-*"
166 set testname "objdump compress debug sections"
167 set got [remote_exec host "$OBJDUMP -W ${compressedfile}.o" "" "/dev/null" "objdump.out"]
168 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
169 fail "$testname"
170 send_log "$got\n"
171 }
172 if { [regexp_diff objdump.out $srcdir/$subdir/dw2-1.W] } then {
173 fail "$testname"
174 } else {
175 pass "$testname"
176 }
177
178 setup_xfail "nds32*-*-*"
179 set testname "objdump compress debug sections 3"
180 set got [remote_exec host "$OBJDUMP -W ${compressedfile3}.o" "" "/dev/null" "objdump.out"]
181 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
182 fail "$testname"
183 send_log "$got\n"
184 }
185 if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3.W] } then {
186 fail "$testname"
187 } else {
188 pass "$testname"
189 }
190
191 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-empty.S ${testfile}empty.o --nocompress-debug-sections] } then {
192 unsupported "compressed debug sections"
193 return
194 }
195
196 set testname "objcopy compress empty debug sections"
197 set got [binutils_run $OBJCOPY "--compress-debug-sections ${testfile}empty.o ${copyfile}empty.o"]
198 if ![string match "" $got] then {
199 fail "objcopy ($testname)"
200 } else {
201 send_log "cmp ${testfile}empty.o ${copyfile}empty.o\n"
202 verbose "cmp ${testfile}empty.o ${copyfile}empty.o"
203 set src1 ${testfile}empty.o
204 set src2 ${copyfile}empty.o
205 set status [remote_exec build cmp "${src1} ${src2}"]
206 set exec_output [lindex $status 1]
207 set exec_output [prune_warnings $exec_output]
208
209 if [string match "" $exec_output] then {
210 pass "objcopy ($testname)"
211 } else {
212 send_log "$exec_output\n"
213 verbose "$exec_output" 1
214 fail "objcopy ($testname)"
215 }
216 }
217
218 if ![is_remote host] {
219 set tempfile tmpdir/debug_str.o
220 set copyfile tmpdir/debug_str.copy
221 } else {
222 set tempfile [remote_download host tmpdir/debug_str.o]
223 set copyfile debug_str.copy
224 }
225
226 run_dump_test "debug_str"
227
228 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gabi.o --compress-debug-sections=zlib-gabi] } then {
229 fail "compressed debug sections with zlib-gabi"
230 return
231 }
232
233 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gnu.o --compress-debug-sections=zlib-gnu] } then {
234 fail "compressed debug sections with zlib-gnu"
235 return
236 }
237
238 set src1 ${compressedfile}gabi.o
239 set src2 ${compressedfile}.o
240 set status [remote_exec build cmp "${src1} ${src2}"]
241 set exec_output [lindex $status 1]
242 set exec_output [prune_warnings $exec_output]
243 if ![string match "" $exec_output] then {
244 fail "compressed debug sections with zlib-gabi"
245 return
246 }
247
248 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}gabi.o --compress-debug-sections=zlib-gabi] } then {
249 fail "compressed debug sections with zlib-gabi"
250 return
251 }
252
253 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}gnu.o --compress-debug-sections=zlib-gnu] } then {
254 fail "compressed debug sections with zlib-gnu"
255 return
256 }
257
258 set src1 ${compressedfile2}gabi.o
259 set src2 ${compressedfile2}.o
260 set status [remote_exec build cmp "${src1} ${src2}"]
261 set exec_output [lindex $status 1]
262 set exec_output [prune_warnings $exec_output]
263 if ![string match "" $exec_output] then {
264 fail "compressed debug sections with zlib-gabi"
265 return
266 }
267
268 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}gabi.o --compress-debug-sections=zlib-gabi] } then {
269 fail "compressed debug sections with zlib-gabi"
270 return
271 }
272
273 set testname "readelf -t zlib-gabi compress debug sections"
274 set got [remote_exec host "$READELF -t --wide ${compressedfile3}gabi.o" "" "/dev/null" "tmpdir/dw2-3.rt"]
275 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
276 fail "$testname (reason: unexpected output)"
277 send_log "$got\n"
278 }
279 if { [regexp_diff tmpdir/dw2-3.rt $srcdir/$subdir/dw2-3.rt] } then {
280 fail "$testname"
281 } else {
282 pass "$testname"
283 }
284
285 set testname "readelf -S zlib-gabi compress debug sections"
286 set got [remote_exec host "$READELF -S --wide ${compressedfile3}gabi.o" "" "/dev/null" "tmpdir/dw2-3.rS"]
287 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
288 fail "$testname (reason: unexpected output)"
289 send_log "$got\n"
290 }
291 if { [regexp_diff tmpdir/dw2-3.rS $srcdir/$subdir/dw2-3.rS] } then {
292 fail "$testname"
293 } else {
294 pass "$testname"
295 }
296
297 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}gnu.o --compress-debug-sections=zlib-gnu] } then {
298 fail "compressed debug sections with zlib-gnu"
299 return
300 }
301
302 set src1 ${compressedfile3}gabi.o
303 set src2 ${compressedfile3}.o
304 set status [remote_exec build cmp "${src1} ${src2}"]
305 set exec_output [lindex $status 1]
306 set exec_output [prune_warnings $exec_output]
307 if ![string match "" $exec_output] then {
308 fail "compressed debug sections with zlib-gabi"
309 return
310 }
311
312 remote_file host delete ${libfile}gabi.a
313 set got [binutils_run $AR "rc ${libfile}gabi.a ${compressedfile}gabi.o ${compressedfile2}gabi.o ${compressedfile3}gabi.o"]
314 if ![string match "" $got] then {
315 fail "compressed debug sections"
316 return
317 }
318
319 set testname "objcopy compress debug sections with zlib-gabi"
320 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${testfile}.o ${copyfile}gabi.o"]
321 if ![string match "" $got] then {
322 fail "objcopy ($testname)"
323 return
324 }
325 send_log "cmp ${compressedfile}gabi.o ${copyfile}gabi.o\n"
326 verbose "cmp ${compressedfile}gabi.o ${copyfile}gabi.o"
327 set src1 ${compressedfile}gabi.o
328 set src2 ${copyfile}gabi.o
329 set status [remote_exec build cmp "${src1} ${src2}"]
330 set exec_output [lindex $status 1]
331 set exec_output [prune_warnings $exec_output]
332 if ![string match "" $exec_output] then {
333 send_log "$exec_output\n"
334 verbose "$exec_output" 1
335 fail "objcopy ($testname)"
336 } else {
337 pass "objcopy ($testname)"
338 }
339
340 set testname "objcopy decompress compressed debug sections with zlib-gabi"
341 set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile}gabi.o ${copyfile}gabi.o"]
342 if ![string match "" $got] then {
343 fail "objcopy ($testname)"
344 return
345 }
346 send_log "cmp ${testfile}.o ${copyfile}gabi.o\n"
347 verbose "cmp ${testfile}.o ${copyfile}gabi.o"
348 set src1 ${testfile}.o
349 set src2 ${copyfile}gabi.o
350 set status [remote_exec build cmp "${src1} ${src2}"]
351 set exec_output [lindex $status 1]
352 set exec_output [prune_warnings $exec_output]
353 if ![string match "" $exec_output] then {
354 send_log "$exec_output\n"
355 verbose "$exec_output" 1
356 fail "objcopy ($testname)"
357 } else {
358 pass "objcopy ($testname)"
359 }
360
361 set testname "objcopy zlib-gnu compress debug sections with zlib-gabi"
362 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${compressedfile}.o ${copyfile}gabi.o"]
363 if ![string match "" $got] then {
364 fail "objcopy ($testname)"
365 return
366 }
367 send_log "cmp ${compressedfile}gabi.o ${copyfile}gabi.o\n"
368 verbose "cmp ${compressedfile}gabi.o ${copyfile}gabi.o"
369 set src1 ${compressedfile}gabi.o
370 set src2 ${copyfile}gabi.o
371 set status [remote_exec build cmp "${src1} ${src2}"]
372 set exec_output [lindex $status 1]
373 set exec_output [prune_warnings $exec_output]
374 if ![string match "" $exec_output] then {
375 send_log "$exec_output\n"
376 verbose "$exec_output" 1
377 fail "objcopy ($testname)"
378 } else {
379 pass "objcopy ($testname)"
380 }
381
382 set testname "objcopy zlib-gabi compress debug sections with zlib-gnu"
383 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${compressedfile}gabi.o ${copyfile}gnu.o"]
384 if ![string match "" $got] then {
385 fail "objcopy ($testname)"
386 return
387 }
388 send_log "cmp ${compressedfile}gnu.o ${copyfile}gnu.o\n"
389 verbose "cmp ${compressedfile}gnu.o ${copyfile}gnu.o"
390 set src1 ${compressedfile}gnu.o
391 set src2 ${copyfile}gnu.o
392 set status [remote_exec build cmp "${src1} ${src2}"]
393 set exec_output [lindex $status 1]
394 set exec_output [prune_warnings $exec_output]
395 if ![string match "" $exec_output] then {
396 send_log "$exec_output\n"
397 verbose "$exec_output" 1
398 fail "objcopy ($testname)"
399 } else {
400 pass "objcopy ($testname)"
401 }
402
403 set testname "objcopy compress debug sections 3 with zlib-gabi"
404 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${testfile3}.o ${copyfile}gabi.o"]
405 if ![string match "" $got] then {
406 fail "objcopy ($testname)"
407 return
408 }
409 send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
410 verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
411 set src1 ${compressedfile3}gabi.o
412 set src2 ${copyfile}gabi.o
413 set status [remote_exec build cmp "${src1} ${src2}"]
414 set exec_output [lindex $status 1]
415 set exec_output [prune_warnings $exec_output]
416 if ![string match "" $exec_output] then {
417 send_log "$exec_output\n"
418 verbose "$exec_output" 1
419 fail "objcopy ($testname)"
420 } else {
421 pass "objcopy ($testname)"
422 }
423
424 set testname "objcopy decompress compressed debug sections 3 with zlib-gabi"
425 set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile3}gabi.o ${copyfile}gabi.o"]
426 if ![string match "" $got] then {
427 fail "objcopy ($testname)"
428 return
429 }
430 send_log "cmp ${testfile3}.o ${copyfile}gabi.o\n"
431 verbose "cmp ${testfile3}.o ${copyfile}gabi.o"
432 set src1 ${testfile3}.o
433 set src2 ${copyfile}gabi.o
434 set status [remote_exec build cmp "${src1} ${src2}"]
435 set exec_output [lindex $status 1]
436 set exec_output [prune_warnings $exec_output]
437 if ![string match "" $exec_output] then {
438 send_log "$exec_output\n"
439 verbose "$exec_output" 1
440 fail "objcopy ($testname)"
441 } else {
442 pass "objcopy ($testname)"
443 }
444
445 set testname "objcopy zlib-gnu compress debug sections 3 with zlib-gabi"
446 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${compressedfile3}.o ${copyfile}gabi.o"]
447 if ![string match "" $got] then {
448 fail "objcopy ($testname)"
449 return
450 }
451 send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
452 verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
453 set src1 ${compressedfile3}gabi.o
454 set src2 ${copyfile}gabi.o
455 set status [remote_exec build cmp "${src1} ${src2}"]
456 set exec_output [lindex $status 1]
457 set exec_output [prune_warnings $exec_output]
458 if ![string match "" $exec_output] then {
459 send_log "$exec_output\n"
460 verbose "$exec_output" 1
461 fail "objcopy ($testname)"
462 } else {
463 pass "objcopy ($testname)"
464 }
465
466 set testname "objcopy zlib-gabi compress debug sections 3 with zlib-gnu"
467 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${compressedfile3}gabi.o ${copyfile}gnu.o"]
468 if ![string match "" $got] then {
469 fail "objcopy ($testname)"
470 return
471 }
472 send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
473 verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
474 set src1 ${compressedfile3}gnu.o
475 set src2 ${copyfile}gnu.o
476 set status [remote_exec build cmp "${src1} ${src2}"]
477 set exec_output [lindex $status 1]
478 set exec_output [prune_warnings $exec_output]
479 if ![string match "" $exec_output] then {
480 send_log "$exec_output\n"
481 verbose "$exec_output" 1
482 fail "objcopy ($testname)"
483 } else {
484 pass "objcopy ($testname)"
485 }
486
487 set testname "objcopy zlib-gnu compress debug sections 3"
488 set got [binutils_run $OBJCOPY "${compressedfile3}gnu.o ${copyfile}gnu.o"]
489 if ![string match "" $got] then {
490 fail "objcopy ($testname)"
491 return
492 }
493 send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
494 verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
495 set src1 ${compressedfile3}gnu.o
496 set src2 ${copyfile}gnu.o
497 set status [remote_exec build cmp "${src1} ${src2}"]
498 set exec_output [lindex $status 1]
499 set exec_output [prune_warnings $exec_output]
500 if ![string match "" $exec_output] then {
501 send_log "$exec_output\n"
502 verbose "$exec_output" 1
503 fail "objcopy ($testname)"
504 } else {
505 pass "objcopy ($testname)"
506 }
507
508 set testname "objcopy zlib-gabi compress debug sections 3"
509 set got [binutils_run $OBJCOPY "${compressedfile3}gabi.o ${copyfile}gabi.o"]
510 if ![string match "" $got] then {
511 fail "objcopy ($testname)"
512 return
513 }
514 send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
515 verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
516 set src1 ${compressedfile3}gabi.o
517 set src2 ${copyfile}gabi.o
518 set status [remote_exec build cmp "${src1} ${src2}"]
519 set exec_output [lindex $status 1]
520 set exec_output [prune_warnings $exec_output]
521 if ![string match "" $exec_output] then {
522 send_log "$exec_output\n"
523 verbose "$exec_output" 1
524 fail "objcopy ($testname)"
525 } else {
526 pass "objcopy ($testname)"
527 }
528
529 set testname "objcopy decompress debug sections in archive with zlib-gabi"
530 set got [binutils_run $OBJCOPY "--decompress-debug-sections ${libfile}gabi.a ${copyfile}gabi.a"]
531 if ![string match "" $got] then {
532 fail "objcopy ($testname)"
533 } else {
534 set got [remote_exec host "$READELF -S --wide ${copyfile}gabi.a" "" "/dev/null" "tmpdir/libdw2.out"]
535
536 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
537 fail "$testname (reason: unexpected output)"
538 send_log $got
539 send_log "\n"
540 }
541
542 if { [regexp_diff tmpdir/libdw2.out $srcdir/$subdir/libdw2.out] } then {
543 fail "$testname"
544 } else {
545 pass "$testname"
546 }
547 }
548
549 setup_xfail "nds32*-*-*"
550 set testname "objcopy compress debug sections in archive with zlib-gabi"
551 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${copyfile}gabi.a ${compressedcopyfile}gabi.a"]
552 if ![string match "" $got] then {
553 fail "objcopy ($testname)"
554 } else {
555 set got [remote_exec host "$OBJDUMP -W ${compressedcopyfile}gabi.a" "" "/dev/null" "tmpdir/libdw2-compressedgabi.out"]
556
557 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
558 fail "$testname (reason: unexpected output)"
559 send_log $got
560 send_log "\n"
561 }
562
563 if { [regexp_diff tmpdir/libdw2-compressedgabi.out $srcdir/$subdir/libdw2-compressedgabi.out] } then {
564 fail "$testname"
565 } else {
566 pass "$testname"
567 }
568 }
569
570 setup_xfail "nds32*-*-*"
571 set testname "objdump compress debug sections 3 with zlib-gabi"
572 set got [remote_exec host "$OBJDUMP -W ${compressedfile3}gabi.o" "" "/dev/null" "objdump.out"]
573 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
574 fail "$testname"
575 send_log "$got\n"
576 }
577 if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3gabi.W] } then {
578 fail "$testname"
579 } else {
580 pass "$testname"
581 }
582
583 proc convert_test { testname as_flags objcop_flags } {
584 global srcdir
585 global subdir
586 global testfile3
587 global copyfile
588 global OBJCOPY
589 global OBJDUMP
590
591 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${testfile3}.o "$as_flags"] } then {
592 unresolved "$testname"
593 return
594 }
595
596 set got [binutils_run $OBJCOPY "$objcop_flags ${testfile3}.o ${copyfile}.o"]
597 if ![string match "" $got] then {
598 fail "objcopy ($testname)"
599 return
600 }
601
602 set got [remote_exec host "$OBJDUMP -W ${copyfile}.o" "" "/dev/null" "objdump.out"]
603
604 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
605 fail "$testname (reason: unexpected output)"
606 send_log $got
607 send_log "\n"
608 return
609 }
610
611 if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3.W] } then {
612 fail "$testname"
613 } else {
614 pass "$testname"
615 }
616 }
617
618 if { ([istarget "x86_64-*-elf*"]
619 || [istarget "x86_64-*-linux*"]) } {
620 set testname "Convert x86-64 object with zlib-gabi to x32 (1)"
621 convert_test "$testname" "--compress-debug-sections=zlib-gabi --64" "-O elf32-x86-64"
622
623 set testname "Convert x86-64 object with zlib-gabi to x32 (2)"
624 convert_test "$testname" "--compress-debug-sections=zlib-gabi --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gnu"
625
626 set testname "Convert x86-64 object with zlib-gabi to x32 (3)"
627 convert_test "$testname" "--compress-debug-sections=zlib-gabi --64" "-O elf32-x86-64 --decompress-debug-sections"
628
629 set testname "Convert x86-64 object with zlib-gnu to x32 (1)"
630 convert_test "$testname" "--compress-debug-sections=zlib-gnu --64" "-O elf32-x86-64"
631
632 set testname "Convert x86-64 object with zlib-gnu to x32 (2)"
633 convert_test "$testname" "--compress-debug-sections=zlib-gnu --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gabi"
634
635 set testname "Convert x86-64 object with zlib-gnu to x32 (3)"
636 convert_test "$testname" "--compress-debug-sections=zlib-gnu --64" "-O elf32-x86-64 --decompress-debug-sections"
637
638 set testname "Convert x86-64 object to x32 (1)"
639 convert_test "$testname" "--nocompress-debug-sections --64" "-O elf32-x86-64"
640
641 set testname "Convert x86-64 object to x32 (2)"
642 convert_test "$testname" "--nocompress-debug-sections --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gabi"
643
644 set testname "Convert x86-64 object to x32 (3)"
645 convert_test "$testname" "--nocompress-debug-sections --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gnu"
646
647
648 set testname "Convert x32 object with zlib-gabi to x86-64 (1)"
649 convert_test "$testname" "--compress-debug-sections=zlib-gabi --x32" "-O elf64-x86-64"
650
651 set testname "Convert x32 object with zlib-gabi to x86-64 (2)"
652 convert_test "$testname" "--compress-debug-sections=zlib-gabi --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gnu"
653
654 set testname "Convert x32 object with zlib-gabi to x86-64 (3)"
655 convert_test "$testname" "--compress-debug-sections=zlib-gabi --x32" "-O elf64-x86-64 --decompress-debug-sections"
656
657 set testname "Convert x32 object with zlib-gnu to x86-64 (1)"
658 convert_test "$testname" "--compress-debug-sections=zlib-gnu --x32" "-O elf64-x86-64"
659
660 set testname "Convert x32 object with zlib-gnu to x86-64 (2)"
661 convert_test "$testname" "--compress-debug-sections=zlib-gnu --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gabi"
662
663 set testname "Convert x32 object with zlib-gnu to x86-64 (3)"
664 convert_test "$testname" "--compress-debug-sections=zlib-gnu --x32" "-O elf64-x86-64 --decompress-debug-sections"
665
666 set testname "Convert x32 object to x86-64 (1)"
667 convert_test "$testname" "--nocompress-debug-sections --x32" "-O elf64-x86-64"
668
669 set testname "Convert x32 object to x86-64 (2)"
670 convert_test "$testname" "--nocompress-debug-sections --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gabi"
671
672 set testname "Convert x32 object to x86-64 (3)"
673 convert_test "$testname" "--nocompress-debug-sections --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gnu"
674 }
675
676 proc test_gnu_debuglink {} {
677 global srcdir
678 global subdir
679 global env
680 global STRIP
681 global OBJCOPY
682 global OBJDUMP
683 global gcc_gas_flag
684
685 set test "gnu-debuglink"
686
687 # Use the newly built assembler and linker.
688 set flags debug
689 if { [istarget *-*-linux*]
690 || [istarget *-*-gnu*] } {
691 foreach i $gcc_gas_flag {
692 set flags "additional_flags=$i $flags"
693 }
694 }
695 if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable $flags] != "" } {
696 unsupported "$test (build)"
697 return
698 }
699 set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.dump"]
700 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
701 fail "$test (objcopy dump)"
702 return
703 }
704 if { [binutils_run $STRIP "--strip-debug --remove-section=.comment --remove-section=.note tmpdir/testprog -o tmpdir/testprog.strip"] != "" } {
705 fail "$test (strip)"
706 return
707 }
708 if { [binutils_run $OBJCOPY "--only-keep-debug --decompress-debug-sections tmpdir/testprog tmpdir/testprog.decompress"] != "" } {
709 fail "$test (objcopy decompress)"
710 return
711 }
712 if { [binutils_run $OBJCOPY "--only-keep-debug --compress-debug-sections tmpdir/testprog tmpdir/testprog.compress"] != "" } {
713 fail "$test (objcopy compress)"
714 return
715 }
716 if { [binutils_run $OBJCOPY "--add-gnu-debuglink=tmpdir/testprog.decompress tmpdir/testprog.strip tmpdir/testprog"] != "" } {
717 fail "$test (objcopy link decompress)"
718 return
719 }
720 set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.decompress.dump"]
721 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
722 fail "$test (objcopy dump decompress)"
723 return
724 }
725 if { [binutils_run $OBJCOPY "--add-gnu-debuglink=tmpdir/testprog.compress tmpdir/testprog.strip tmpdir/testprog"] != "" } {
726 fail "$test (objcopy link compress)"
727 return
728 }
729 set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.compress.dump"]
730 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
731 fail "$test (objcopy dump compress)"
732 return
733 }
734
735 set src1 tmpdir/testprog.dump
736 set src2 tmpdir/testprog.compress.dump
737 send_log "cmp ${src1} ${src2}\n"
738 verbose "cmp ${src1} ${src2}"
739 set status [remote_exec build cmp "${src1} ${src2}"]
740 set exec_output [lindex $status 1]
741 set exec_output [prune_warnings $exec_output]
742 if ![string match "" $exec_output] then {
743 send_log "$exec_output\n"
744 verbose "$exec_output" 1
745 fail "$test (objdump 1)"
746 } else {
747 pass "$test (objdump 1)"
748 }
749
750 set src1 tmpdir/testprog.decompress.dump
751 set src2 tmpdir/testprog.compress.dump
752 send_log "cmp ${src1} ${src2}\n"
753 verbose "cmp ${src1} ${src2}"
754 set status [remote_exec build cmp "${src1} ${src2}"]
755 set exec_output [lindex $status 1]
756 set exec_output [prune_warnings $exec_output]
757 if ![string match "" $exec_output] then {
758 send_log "$exec_output\n"
759 verbose "$exec_output" 1
760 fail "$test (objdump 2)"
761 } else {
762 pass "$test (objdump 2)"
763 }
764 }
765
766 if {[is_elf_format]} then {
767 test_gnu_debuglink
768 }