Update year range in copyright notice of binutils files
[deliverable/binutils-gdb.git] / binutils / testsuite / binutils-all / compress.exp
CommitLineData
b3adc24a 1# Copyright (C) 2010-2020 Free Software Foundation, Inc.
4a114e3e
L
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.
65951855 7#
4a114e3e
L
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.
65951855 12#
4a114e3e
L
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
dae148f3 19if { [is_remote host] || ![is_elf_format] } then {
4a114e3e
L
20 return
21}
22
e268c0a6
L
23set testfile tmpdir/dw2-1
24set compressedfile tmpdir/dw2-1-compressed
4a114e3e 25set copyfile tmpdir/dw2-copy
e268c0a6
L
26set compressedfile2 tmpdir/dw2-2-compressed
27set libfile tmpdir/libdw2
4a114e3e 28set compressedcopyfile tmpdir/dw2-copy-compressed
e268c0a6
L
29set testfile3 tmpdir/dw2-3
30set compressedfile3 tmpdir/dw2-3-compressed
4a114e3e 31
e268c0a6 32if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${testfile}.o --nocompress-debug-sections] } then {
6dbf72d7 33 unsupported "compressed debug sections"
4a114e3e
L
34 return
35}
36
e268c0a6 37if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}.o --compress-debug-sections] } then {
4a114e3e
L
38 unsupported "compressed debug sections"
39 return
40}
41
19a7fe52
L
42if { ![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
47set got [remote_exec host "cmp ${testfile}.o ${compressedfile}gnu.o"]
317974f6
L
48# Use it to set up xfail.
49set exec_output [lindex $got 1]
50if [string match "" $exec_output] then {
51 set compression_used ""
52} else {
53 set compression_used "yes"
54}
55
e268c0a6 56if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}.o --compress-debug-sections] } then {
4a114e3e
L
57 unsupported "compressed debug sections"
58 return
59}
60
e268c0a6
L
61if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${testfile3}.o --nocompress-debug-sections] } then {
62 unsupported "compressed debug sections"
63 return
64}
65
66if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}.o --compress-debug-sections] } then {
67 unsupported "compressed debug sections"
68 return
69}
70
71remote_file host delete ${libfile}.a
72set got [binutils_run $AR "rc ${libfile}.a ${compressedfile}.o ${compressedfile2}.o ${compressedfile3}.o"]
4a114e3e
L
73if ![string match "" $got] then {
74 fail "compressed debug sections"
75 return
76}
77
78set testname "objcopy compress debug sections"
e268c0a6 79set got [binutils_run $OBJCOPY "--compress-debug-sections ${testfile}.o ${copyfile}.o"]
4a114e3e
L
80if ![string match "" $got] then {
81 fail "objcopy ($testname)"
82} else {
e268c0a6
L
83 send_log "cmp ${compressedfile}.o ${copyfile}.o\n"
84 verbose "cmp ${compressedfile}.o ${copyfile}.o"
85 set src1 ${compressedfile}.o
4a114e3e
L
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
100set testname "objcopy decompress compressed debug sections"
e268c0a6 101set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile}.o ${copyfile}.o"]
4a114e3e
L
102if ![string match "" $got] then {
103 fail "objcopy ($testname)"
104} else {
e268c0a6
L
105 send_log "cmp ${testfile}.o ${copyfile}.o\n"
106 verbose "cmp ${testfile}.o ${copyfile}.o"
107 set src1 ${testfile}.o
4a114e3e
L
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
122set testname "objcopy decompress debug sections in archive"
e268c0a6 123set got [binutils_run $OBJCOPY "--decompress-debug-sections ${libfile}.a ${copyfile}.a"]
4a114e3e
L
124if ![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
317974f6
L
142# Xfail this test if there are no compressed sections.
143setup_xfail "$compression_used$target_triplet"
19a7fe52
L
144set testname "objcopy compress debug sections in archive with zlib-gnu"
145set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${copyfile}.a ${compressedcopyfile}.a"]
4a114e3e
L
146if ![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
317974f6 157 setup_xfail "$compression_used$target_triplet"
4a114e3e
L
158 if { [regexp_diff tmpdir/libdw2-compressed.out $srcdir/$subdir/libdw2-compressed.out] } then {
159 fail "$testname"
160 } else {
161 pass "$testname"
162 }
163}
5a5ed5b0 164
96037eb0 165setup_xfail "nds32*-*-*"
a9481b58 166set testname "objdump compress debug sections"
e268c0a6 167set got [remote_exec host "$OBJDUMP -W ${compressedfile}.o" "" "/dev/null" "objdump.out"]
a9481b58
L
168if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
169 fail "$testname"
170 send_log "$got\n"
171}
172if { [regexp_diff objdump.out $srcdir/$subdir/dw2-1.W] } then {
173 fail "$testname"
174} else {
175 pass "$testname"
176}
177
96037eb0 178setup_xfail "nds32*-*-*"
e268c0a6
L
179set testname "objdump compress debug sections 3"
180set got [remote_exec host "$OBJDUMP -W ${compressedfile3}.o" "" "/dev/null" "objdump.out"]
181if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
182 fail "$testname"
183 send_log "$got\n"
184}
185if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3.W] } then {
186 fail "$testname"
187} else {
188 pass "$testname"
189}
5a5ed5b0 190
e268c0a6 191if { ![binutils_assemble_flags $srcdir/$subdir/dw2-empty.S ${testfile}empty.o --nocompress-debug-sections] } then {
5a5ed5b0
L
192 unsupported "compressed debug sections"
193 return
194}
195
196set testname "objcopy compress empty debug sections"
e268c0a6 197set got [binutils_run $OBJCOPY "--compress-debug-sections ${testfile}empty.o ${copyfile}empty.o"]
5a5ed5b0
L
198if ![string match "" $got] then {
199 fail "objcopy ($testname)"
200} else {
e268c0a6
L
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
5a5ed5b0
L
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}
a953eec9
NC
217
218if ![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
226run_dump_test "debug_str"
151411f8
L
227
228if { ![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
233if { ![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
19a7fe52 238set src1 ${compressedfile}gabi.o
151411f8
L
239set src2 ${compressedfile}.o
240set status [remote_exec build cmp "${src1} ${src2}"]
241set exec_output [lindex $status 1]
242set exec_output [prune_warnings $exec_output]
243if ![string match "" $exec_output] then {
19a7fe52 244 fail "compressed debug sections with zlib-gabi"
151411f8
L
245 return
246}
247
248if { ![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
253if { ![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
19a7fe52 258set src1 ${compressedfile2}gabi.o
151411f8
L
259set src2 ${compressedfile2}.o
260set status [remote_exec build cmp "${src1} ${src2}"]
261set exec_output [lindex $status 1]
262set exec_output [prune_warnings $exec_output]
263if ![string match "" $exec_output] then {
19a7fe52 264 fail "compressed debug sections with zlib-gabi"
151411f8
L
265 return
266}
267
268if { ![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
273set testname "readelf -t zlib-gabi compress debug sections"
274set got [remote_exec host "$READELF -t --wide ${compressedfile3}gabi.o" "" "/dev/null" "tmpdir/dw2-3.rt"]
275if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
276 fail "$testname (reason: unexpected output)"
277 send_log "$got\n"
278}
279if { [regexp_diff tmpdir/dw2-3.rt $srcdir/$subdir/dw2-3.rt] } then {
280 fail "$testname"
281} else {
282 pass "$testname"
283}
284
285set testname "readelf -S zlib-gabi compress debug sections"
286set got [remote_exec host "$READELF -S --wide ${compressedfile3}gabi.o" "" "/dev/null" "tmpdir/dw2-3.rS"]
287if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
288 fail "$testname (reason: unexpected output)"
289 send_log "$got\n"
290}
291if { [regexp_diff tmpdir/dw2-3.rS $srcdir/$subdir/dw2-3.rS] } then {
292 fail "$testname"
293} else {
294 pass "$testname"
295}
296
297if { ![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
19a7fe52 302set src1 ${compressedfile3}gabi.o
151411f8
L
303set src2 ${compressedfile3}.o
304set status [remote_exec build cmp "${src1} ${src2}"]
305set exec_output [lindex $status 1]
306set exec_output [prune_warnings $exec_output]
307if ![string match "" $exec_output] then {
19a7fe52 308 fail "compressed debug sections with zlib-gabi"
151411f8
L
309 return
310}
311
312remote_file host delete ${libfile}gabi.a
313set got [binutils_run $AR "rc ${libfile}gabi.a ${compressedfile}gabi.o ${compressedfile2}gabi.o ${compressedfile3}gabi.o"]
314if ![string match "" $got] then {
315 fail "compressed debug sections"
316 return
317}
318
319set testname "objcopy compress debug sections with zlib-gabi"
320set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${testfile}.o ${copyfile}gabi.o"]
321if ![string match "" $got] then {
322 fail "objcopy ($testname)"
323 return
324}
325send_log "cmp ${compressedfile}gabi.o ${copyfile}gabi.o\n"
326verbose "cmp ${compressedfile}gabi.o ${copyfile}gabi.o"
327set src1 ${compressedfile}gabi.o
328set src2 ${copyfile}gabi.o
329set status [remote_exec build cmp "${src1} ${src2}"]
330set exec_output [lindex $status 1]
331set exec_output [prune_warnings $exec_output]
332if ![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
340set testname "objcopy decompress compressed debug sections with zlib-gabi"
341set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile}gabi.o ${copyfile}gabi.o"]
342if ![string match "" $got] then {
343 fail "objcopy ($testname)"
344 return
345}
346send_log "cmp ${testfile}.o ${copyfile}gabi.o\n"
347verbose "cmp ${testfile}.o ${copyfile}gabi.o"
348set src1 ${testfile}.o
349set src2 ${copyfile}gabi.o
350set status [remote_exec build cmp "${src1} ${src2}"]
351set exec_output [lindex $status 1]
352set exec_output [prune_warnings $exec_output]
353if ![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
361set testname "objcopy zlib-gnu compress debug sections with zlib-gabi"
362set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${compressedfile}.o ${copyfile}gabi.o"]
363if ![string match "" $got] then {
364 fail "objcopy ($testname)"
365 return
366}
367send_log "cmp ${compressedfile}gabi.o ${copyfile}gabi.o\n"
368verbose "cmp ${compressedfile}gabi.o ${copyfile}gabi.o"
369set src1 ${compressedfile}gabi.o
370set src2 ${copyfile}gabi.o
371set status [remote_exec build cmp "${src1} ${src2}"]
372set exec_output [lindex $status 1]
373set exec_output [prune_warnings $exec_output]
374if ![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
382set testname "objcopy zlib-gabi compress debug sections with zlib-gnu"
383set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${compressedfile}gabi.o ${copyfile}gnu.o"]
384if ![string match "" $got] then {
385 fail "objcopy ($testname)"
386 return
387}
388send_log "cmp ${compressedfile}gnu.o ${copyfile}gnu.o\n"
389verbose "cmp ${compressedfile}gnu.o ${copyfile}gnu.o"
390set src1 ${compressedfile}gnu.o
391set src2 ${copyfile}gnu.o
392set status [remote_exec build cmp "${src1} ${src2}"]
393set exec_output [lindex $status 1]
394set exec_output [prune_warnings $exec_output]
395if ![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
403set testname "objcopy compress debug sections 3 with zlib-gabi"
404set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${testfile3}.o ${copyfile}gabi.o"]
405if ![string match "" $got] then {
406 fail "objcopy ($testname)"
407 return
408}
409send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
410verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
411set src1 ${compressedfile3}gabi.o
412set src2 ${copyfile}gabi.o
413set status [remote_exec build cmp "${src1} ${src2}"]
414set exec_output [lindex $status 1]
415set exec_output [prune_warnings $exec_output]
416if ![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
424set testname "objcopy decompress compressed debug sections 3 with zlib-gabi"
425set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile3}gabi.o ${copyfile}gabi.o"]
426if ![string match "" $got] then {
427 fail "objcopy ($testname)"
428 return
429}
430send_log "cmp ${testfile3}.o ${copyfile}gabi.o\n"
431verbose "cmp ${testfile3}.o ${copyfile}gabi.o"
432set src1 ${testfile3}.o
433set src2 ${copyfile}gabi.o
434set status [remote_exec build cmp "${src1} ${src2}"]
435set exec_output [lindex $status 1]
436set exec_output [prune_warnings $exec_output]
437if ![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
445set testname "objcopy zlib-gnu compress debug sections 3 with zlib-gabi"
446set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${compressedfile3}.o ${copyfile}gabi.o"]
447if ![string match "" $got] then {
448 fail "objcopy ($testname)"
449 return
450}
451send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
452verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
453set src1 ${compressedfile3}gabi.o
454set src2 ${copyfile}gabi.o
455set status [remote_exec build cmp "${src1} ${src2}"]
456set exec_output [lindex $status 1]
457set exec_output [prune_warnings $exec_output]
458if ![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
466set testname "objcopy zlib-gabi compress debug sections 3 with zlib-gnu"
467set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${compressedfile3}gabi.o ${copyfile}gnu.o"]
468if ![string match "" $got] then {
469 fail "objcopy ($testname)"
470 return
471}
472send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
473verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
474set src1 ${compressedfile3}gnu.o
475set src2 ${copyfile}gnu.o
476set status [remote_exec build cmp "${src1} ${src2}"]
477set exec_output [lindex $status 1]
478set exec_output [prune_warnings $exec_output]
479if ![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
487set testname "objcopy zlib-gnu compress debug sections 3"
488set got [binutils_run $OBJCOPY "${compressedfile3}gnu.o ${copyfile}gnu.o"]
489if ![string match "" $got] then {
490 fail "objcopy ($testname)"
491 return
492}
493send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
494verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
495set src1 ${compressedfile3}gnu.o
496set src2 ${copyfile}gnu.o
497set status [remote_exec build cmp "${src1} ${src2}"]
498set exec_output [lindex $status 1]
499set exec_output [prune_warnings $exec_output]
500if ![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
a0a8a934
NC
508set testname "objcopy zlib-gabi compress debug sections 3"
509set got [binutils_run $OBJCOPY "${compressedfile3}gabi.o ${copyfile}gabi.o"]
151411f8
L
510if ![string match "" $got] then {
511 fail "objcopy ($testname)"
512 return
513}
a0a8a934
NC
514send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
515verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
516set src1 ${compressedfile3}gabi.o
517set src2 ${copyfile}gabi.o
151411f8
L
518set status [remote_exec build cmp "${src1} ${src2}"]
519set exec_output [lindex $status 1]
520set exec_output [prune_warnings $exec_output]
521if ![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
529set testname "objcopy decompress debug sections in archive with zlib-gabi"
530set got [binutils_run $OBJCOPY "--decompress-debug-sections ${libfile}gabi.a ${copyfile}gabi.a"]
531if ![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
96037eb0 549setup_xfail "nds32*-*-*"
151411f8
L
550set testname "objcopy compress debug sections in archive with zlib-gabi"
551set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${copyfile}gabi.a ${compressedcopyfile}gabi.a"]
552if ![string match "" $got] then {
553 fail "objcopy ($testname)"
554} else {
dab394de 555 set got [remote_exec host "$OBJDUMP -W ${compressedcopyfile}gabi.a" "" "/dev/null" "tmpdir/libdw2-compressedgabi.out"]
151411f8
L
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
96037eb0 570setup_xfail "nds32*-*-*"
151411f8
L
571set testname "objdump compress debug sections 3 with zlib-gabi"
572set got [remote_exec host "$OBJDUMP -W ${compressedfile3}gabi.o" "" "/dev/null" "objdump.out"]
573if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
574 fail "$testname"
575 send_log "$got\n"
576}
f6fe1ccd 577if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3gabi.W] } then {
151411f8
L
578 fail "$testname"
579} else {
580 pass "$testname"
581}
88988473
L
582
583proc 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
618if { ([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"
bf150a0b
L
674}
675
676proc test_gnu_debuglink {} {
677 global srcdir
678 global subdir
679 global env
bf150a0b
L
680 global STRIP
681 global OBJCOPY
682 global OBJDUMP
683
684 set test "gnu-debuglink"
bf150a0b 685
2ecde2b6 686 if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug] != "" } {
bb3b5316 687 unsupported "$test (build)"
bf150a0b
L
688 return
689 }
690 set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.dump"]
691 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
692 fail "$test (objcopy dump)"
693 return
694 }
695 if { [binutils_run $STRIP "--strip-debug --remove-section=.comment --remove-section=.note tmpdir/testprog -o tmpdir/testprog.strip"] != "" } {
696 fail "$test (strip)"
697 return
698 }
699 if { [binutils_run $OBJCOPY "--only-keep-debug --decompress-debug-sections tmpdir/testprog tmpdir/testprog.decompress"] != "" } {
700 fail "$test (objcopy decompress)"
701 return
702 }
703 if { [binutils_run $OBJCOPY "--only-keep-debug --compress-debug-sections tmpdir/testprog tmpdir/testprog.compress"] != "" } {
704 fail "$test (objcopy compress)"
705 return
706 }
707 if { [binutils_run $OBJCOPY "--add-gnu-debuglink=tmpdir/testprog.decompress tmpdir/testprog.strip tmpdir/testprog"] != "" } {
708 fail "$test (objcopy link decompress)"
709 return
710 }
711 set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.decompress.dump"]
712 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
713 fail "$test (objcopy dump decompress)"
714 return
715 }
716 if { [binutils_run $OBJCOPY "--add-gnu-debuglink=tmpdir/testprog.compress tmpdir/testprog.strip tmpdir/testprog"] != "" } {
717 fail "$test (objcopy link compress)"
718 return
719 }
720 set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.compress.dump"]
721 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
722 fail "$test (objcopy dump compress)"
723 return
724 }
725
726 set src1 tmpdir/testprog.dump
727 set src2 tmpdir/testprog.compress.dump
728 send_log "cmp ${src1} ${src2}\n"
729 verbose "cmp ${src1} ${src2}"
730 set status [remote_exec build cmp "${src1} ${src2}"]
731 set exec_output [lindex $status 1]
732 set exec_output [prune_warnings $exec_output]
733 if ![string match "" $exec_output] then {
734 send_log "$exec_output\n"
735 verbose "$exec_output" 1
736 fail "$test (objdump 1)"
737 } else {
738 pass "$test (objdump 1)"
739 }
740
741 set src1 tmpdir/testprog.decompress.dump
742 set src2 tmpdir/testprog.compress.dump
743 send_log "cmp ${src1} ${src2}\n"
744 verbose "cmp ${src1} ${src2}"
745 set status [remote_exec build cmp "${src1} ${src2}"]
746 set exec_output [lindex $status 1]
747 set exec_output [prune_warnings $exec_output]
748 if ![string match "" $exec_output] then {
749 send_log "$exec_output\n"
750 verbose "$exec_output" 1
751 fail "$test (objdump 2)"
752 } else {
753 pass "$test (objdump 2)"
754 }
755}
756
0034eed0 757if {[is_elf_format]} then {
bf150a0b
L
758 test_gnu_debuglink
759}
This page took 0.42952 seconds and 4 git commands to generate.