aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-04-08 07:53:54 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-04-08 07:54:09 -0700
commit151411f8af16723a12e0e0eedc1ecdbea648c1b0 (patch)
treec1e9bd46096b7c153f60c144429f6ba52d07fa43 /binutils
parentbfcf0ccd0131621213c5d6f2908cd703a90176f7 (diff)
downloadgdb-151411f8af16723a12e0e0eedc1ecdbea648c1b0.zip
gdb-151411f8af16723a12e0e0eedc1ecdbea648c1b0.tar.gz
gdb-151411f8af16723a12e0e0eedc1ecdbea648c1b0.tar.bz2
Add SHF_COMPRESSED support to gas and objcopy
This patch adds --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi} options to gas and objcopy for ELF files. They control how DWARF debug sections are compressed. --compress-debug-sections=none is equivalent to --nocompress-debug-sections. --compress-debug-sections=zlib and --compress-debug-sections=zlib-gnu are equivalent to --compress-debug-sections. --compress-debug-sections=zlib-gabi compresses DWARF debug sections with SHF_COMPRESSED from the ELF ABI. No linker changes are required to support SHF_COMPRESSED. bfd/ * archive.c (_bfd_get_elt_at_filepos): Also copy BFD_COMPRESS_GABI bit. * bfd.c (bfd::flags): Increase size to 18 bits. (BFD_COMPRESS_GABI): New. (BFD_FLAGS_SAVED): Add BFD_COMPRESS_GABI. (BFD_FLAGS_FOR_BFD_USE_MASK): Likewise. (bfd_update_compression_header): New fuction. (bfd_check_compression_header): Likewise. (bfd_get_compression_header_size): Likewise. (bfd_is_section_compressed_with_header): Likewise. * compress.c (MAX_COMPRESSION_HEADER_SIZE): New. (bfd_compress_section_contents): Return the uncompressed size if the full section contents is compressed successfully. Support converting from/to .zdebug* sections. (bfd_get_full_section_contents): Call bfd_get_compression_header_size to get compression header size. (bfd_is_section_compressed): Renamed to ... (bfd_is_section_compressed_with_header): This. Add a pointer argument to return compression header size. (bfd_is_section_compressed): Use it. (bfd_init_section_decompress_status): Call bfd_get_compression_header_size to get compression header size. Return FALSE if uncompressed section size is 0. * elf.c (_bfd_elf_make_section_from_shdr): Support converting from/to .zdebug* sections. * bfd-in2.h: Regenerated. binutils/ * objcopy.c (do_debug_sections): Add compress_zlib, compress_gnu_zlib and compress_gabi_zlib. (copy_options): Use optional_argument on compress-debug-sections. (copy_usage): Update --compress-debug-sections. (copy_file): Handle compress_zlib, compress_gnu_zlib and compress_gabi_zlib. (copy_main): Handle --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. * doc/binutils.texi: Document --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. binutils/testsuite/ * compress.exp: Add tests for --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. * binutils-all/dw2-3.rS: New file. * binutils-all/dw2-3.rt: Likewise. * binutils-all/libdw2-compressedgabi.out: Likewise. gas/ * as.c (show_usage): Update --compress-debug-sections. (std_longopts): Use optional_argument on compress-debug-sections. (parse_args): Handle --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. * as.h (compressed_debug_section_type): New. (flag_compress_debug): Change type to compressed_debug_section_type. --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. * write.c (compress_debug): Set BFD_COMPRESS_GABI for --compress-debug-sections=zlib-gabi. Call bfd_get_compression_header_size to get compression header size. Don't rename section name for --compress-debug-sections=zlib-gabi. * config/tc-i386.c (compressed_debug_section_type): Set to COMPRESS_DEBUG_ZLIB. * doc/as.texinfo: Document --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. gas/testsuite/ * gas/i386/dw2-compressed-1.d: New file. * gas/i386/dw2-compressed-2.d: Likewise. * gas/i386/dw2-compressed-3.d: Likewise. * gas/i386/x86-64-dw2-compressed-2.d: Likewise. * gas/i386/i386.exp: Run dw2-compressed-2, dw2-compressed-1, dw2-compressed-3 and x86-64-dw2-compressed-2. ld/testsuite/ * ld-elf/compress.exp: Add a test for --compress-debug-sections=zlib-gabi. (build_tests): Add 2 tests for --compress-debug-sections=zlib-gabi. (run_tests): Likewise. Verify linker output with zlib-gabi compressed debug input. * ld-elf/compressed1a.d: New file. * ld-elf/compressed1b.d: Likewise. * ld-elf/compressed1c.d: Likewise.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog13
-rw-r--r--binutils/doc/binutils.texi13
-rw-r--r--binutils/objcopy.c36
-rw-r--r--binutils/testsuite/ChangeLog8
-rw-r--r--binutils/testsuite/binutils-all/compress.exp354
-rw-r--r--binutils/testsuite/binutils-all/dw2-3.rS3
-rw-r--r--binutils/testsuite/binutils-all/dw2-3.rt6
-rw-r--r--binutils/testsuite/binutils-all/libdw2-compressedgabi.out3
8 files changed, 433 insertions, 3 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index bbc00b9..7d5b1a0 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,18 @@
2015-04-08 H.J. Lu <hongjiu.lu@intel.com>
+ * objcopy.c (do_debug_sections): Add compress_zlib,
+ compress_gnu_zlib and compress_gabi_zlib.
+ (copy_options): Use optional_argument on compress-debug-sections.
+ (copy_usage): Update --compress-debug-sections.
+ (copy_file): Handle compress_zlib, compress_gnu_zlib and
+ compress_gabi_zlib.
+ (copy_main): Handle
+ --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
+ * doc/binutils.texi: Document
+ --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
+
+2015-04-08 H.J. Lu <hongjiu.lu@intel.com>
+
* objcopy.c (copy_usage): Replace "--interleave [<number>]" with
--interleave[=<number>].
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index e0527aa..dbf44c9 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -1849,6 +1849,19 @@ renamed to begin with @samp{.zdebug} instead of @samp{.debug}. Note -
if compression would actually make a section @emph{larger} then it is
not compressed or renamed.
+@item --compress-debug-sections=none
+@itemx --compress-debug-sections=zlib
+@itemx --compress-debug-sections=zlib-gnu
+@itemx --compress-debug-sections=zlib-gabi
+For ELF files, these options control how DWARF debug sections are
+compressed. @option{--compress-debug-sections=none} is equivalent
+to @option{--nocompress-debug-sections}.
+@option{--compress-debug-sections=zlib} and
+@option{--compress-debug-sections=zlib-gnu} are equivalent to
+@option{--compress-debug-sections}.
+@option{--compress-debug-sections=zlib-gabi} compresses
+DWARF debug sections with SHF_COMPRESSED from the ELF ABI.
+
@item --decompress-debug-sections
Decompress DWARF debug sections using zlib. The original section
names of the compressed sections are restored.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index a21006a..a0452c9 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -204,6 +204,9 @@ static enum
{
nothing,
compress,
+ compress_zlib,
+ compress_gnu_zlib,
+ compress_gabi_zlib,
decompress
} do_debug_sections = nothing;
@@ -380,7 +383,7 @@ static struct option copy_options[] =
{"change-section-vma", required_argument, 0, OPTION_CHANGE_SECTION_VMA},
{"change-start", required_argument, 0, OPTION_CHANGE_START},
{"change-warnings", no_argument, 0, OPTION_CHANGE_WARNINGS},
- {"compress-debug-sections", no_argument, 0, OPTION_COMPRESS_DEBUG_SECTIONS},
+ {"compress-debug-sections", optional_argument, 0, OPTION_COMPRESS_DEBUG_SECTIONS},
{"debugging", no_argument, 0, OPTION_DEBUGGING},
{"decompress-debug-sections", no_argument, 0, OPTION_DECOMPRESS_DEBUG_SECTIONS},
{"disable-deterministic-archives", no_argument, 0, 'U'},
@@ -601,7 +604,8 @@ copy_usage (FILE *stream, int exit_status)
<commit>\n\
--subsystem <name>[:<version>]\n\
Set PE subsystem to <name> [& <version>]\n\
- --compress-debug-sections Compress DWARF debug sections using zlib\n\
+ --compress-debug-sections[={none|zlib|zlib-gnu|zlib-gabi}]\n\
+ Compress DWARF debug sections using zlib\n\
--decompress-debug-sections Decompress DWARF debug sections using zlib\n\
-v --verbose List all object files modified\n\
@<file> Read options from <file>\n\
@@ -2588,7 +2592,18 @@ copy_file (const char *input_filename, const char *output_filename,
switch (do_debug_sections)
{
case compress:
+ case compress_zlib:
+ case compress_gnu_zlib:
+ case compress_gabi_zlib:
ibfd->flags |= BFD_COMPRESS;
+ if (do_debug_sections != compress)
+ {
+ if (ibfd->xvec->flavour != bfd_target_elf_flavour)
+ fatal (_("--compress-debug-sections=[zlib|zlib-gnu|zlib-gabi] is unsupported for `%s'"),
+ bfd_get_target (ibfd));
+ if (do_debug_sections == compress_gabi_zlib)
+ ibfd->flags |= BFD_COMPRESS_GABI;
+ }
break;
case decompress:
ibfd->flags |= BFD_DECOMPRESS;
@@ -3998,7 +4013,22 @@ copy_main (int argc, char *argv[])
break;
case OPTION_COMPRESS_DEBUG_SECTIONS:
- do_debug_sections = compress;
+ if (optarg)
+ {
+ if (strcasecmp (optarg, "none") == 0)
+ do_debug_sections = decompress;
+ else if (strcasecmp (optarg, "zlib") == 0)
+ do_debug_sections = compress_zlib;
+ else if (strcasecmp (optarg, "zlib-gnu") == 0)
+ do_debug_sections = compress_gnu_zlib;
+ else if (strcasecmp (optarg, "zlib-gabi") == 0)
+ do_debug_sections = compress_gabi_zlib;
+ else
+ fatal (_("unrecognized --compress-debug-sections type `%s'"),
+ optarg);
+ }
+ else
+ do_debug_sections = compress;
break;
case OPTION_DEBUGGING:
diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog
index ece81a6..b97f412 100644
--- a/binutils/testsuite/ChangeLog
+++ b/binutils/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2015-04-08 H.J. Lu <hongjiu.lu@intel.com>
+
+ * compress.exp: Add tests for
+ --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
+ * binutils-all/dw2-3.rS: New file.
+ * binutils-all/dw2-3.rt: Likewise.
+ * binutils-all/libdw2-compressedgabi.out: Likewise.
+
2015-04-06 H.J. Lu <hongjiu.lu@intel.com>
* binutils-all/compress.exp: Remove is_zlib_supported check.
diff --git a/binutils/testsuite/binutils-all/compress.exp b/binutils/testsuite/binutils-all/compress.exp
index 36b2a26..4d3b71c 100644
--- a/binutils/testsuite/binutils-all/compress.exp
+++ b/binutils/testsuite/binutils-all/compress.exp
@@ -217,3 +217,357 @@ if ![is_remote host] {
}
run_dump_test "debug_str"
+
+if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gabi.o --compress-debug-sections=zlib-gabi] } then {
+ fail "compressed debug sections with zlib-gabi"
+ return
+}
+
+if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gnu.o --compress-debug-sections=zlib-gnu] } then {
+ fail "compressed debug sections with zlib-gnu"
+ return
+}
+
+set src1 ${compressedfile}gnu.o
+set src2 ${compressedfile}.o
+set status [remote_exec build cmp "${src1} ${src2}"]
+set exec_output [lindex $status 1]
+set exec_output [prune_warnings $exec_output]
+if ![string match "" $exec_output] then {
+ fail "compressed debug sections with zlib-gnu"
+ return
+}
+
+if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}gabi.o --compress-debug-sections=zlib-gabi] } then {
+ fail "compressed debug sections with zlib-gabi"
+ return
+}
+
+if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}gnu.o --compress-debug-sections=zlib-gnu] } then {
+ fail "compressed debug sections with zlib-gnu"
+ return
+}
+
+set src1 ${compressedfile2}gnu.o
+set src2 ${compressedfile2}.o
+set status [remote_exec build cmp "${src1} ${src2}"]
+set exec_output [lindex $status 1]
+set exec_output [prune_warnings $exec_output]
+if ![string match "" $exec_output] then {
+ fail "compressed debug sections with zlib-gnu"
+ return
+}
+
+if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}gabi.o --compress-debug-sections=zlib-gabi] } then {
+ fail "compressed debug sections with zlib-gabi"
+ return
+}
+
+set testname "readelf -t zlib-gabi compress debug sections"
+set got [remote_exec host "$READELF -t --wide ${compressedfile3}gabi.o" "" "/dev/null" "tmpdir/dw2-3.rt"]
+if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+ fail "$testname (reason: unexpected output)"
+ send_log "$got\n"
+}
+if { [regexp_diff tmpdir/dw2-3.rt $srcdir/$subdir/dw2-3.rt] } then {
+ fail "$testname"
+} else {
+ pass "$testname"
+}
+
+set testname "readelf -S zlib-gabi compress debug sections"
+set got [remote_exec host "$READELF -S --wide ${compressedfile3}gabi.o" "" "/dev/null" "tmpdir/dw2-3.rS"]
+if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+ fail "$testname (reason: unexpected output)"
+ send_log "$got\n"
+}
+if { [regexp_diff tmpdir/dw2-3.rS $srcdir/$subdir/dw2-3.rS] } then {
+ fail "$testname"
+} else {
+ pass "$testname"
+}
+
+if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}gnu.o --compress-debug-sections=zlib-gnu] } then {
+ fail "compressed debug sections with zlib-gnu"
+ return
+}
+
+set src1 ${compressedfile3}gnu.o
+set src2 ${compressedfile3}.o
+set status [remote_exec build cmp "${src1} ${src2}"]
+set exec_output [lindex $status 1]
+set exec_output [prune_warnings $exec_output]
+if ![string match "" $exec_output] then {
+ fail "compressed debug sections with zlib-gnu"
+ return
+}
+
+remote_file host delete ${libfile}gabi.a
+set got [binutils_run $AR "rc ${libfile}gabi.a ${compressedfile}gabi.o ${compressedfile2}gabi.o ${compressedfile3}gabi.o"]
+if ![string match "" $got] then {
+ fail "compressed debug sections"
+ return
+}
+
+set testname "objcopy compress debug sections with zlib-gabi"
+set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${testfile}.o ${copyfile}gabi.o"]
+if ![string match "" $got] then {
+ fail "objcopy ($testname)"
+ return
+}
+send_log "cmp ${compressedfile}gabi.o ${copyfile}gabi.o\n"
+verbose "cmp ${compressedfile}gabi.o ${copyfile}gabi.o"
+set src1 ${compressedfile}gabi.o
+set src2 ${copyfile}gabi.o
+set status [remote_exec build cmp "${src1} ${src2}"]
+set exec_output [lindex $status 1]
+set exec_output [prune_warnings $exec_output]
+if ![string match "" $exec_output] then {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail "objcopy ($testname)"
+} else {
+ pass "objcopy ($testname)"
+}
+
+set testname "objcopy decompress compressed debug sections with zlib-gabi"
+set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile}gabi.o ${copyfile}gabi.o"]
+if ![string match "" $got] then {
+ fail "objcopy ($testname)"
+ return
+}
+send_log "cmp ${testfile}.o ${copyfile}gabi.o\n"
+verbose "cmp ${testfile}.o ${copyfile}gabi.o"
+set src1 ${testfile}.o
+set src2 ${copyfile}gabi.o
+set status [remote_exec build cmp "${src1} ${src2}"]
+set exec_output [lindex $status 1]
+set exec_output [prune_warnings $exec_output]
+if ![string match "" $exec_output] then {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail "objcopy ($testname)"
+} else {
+ pass "objcopy ($testname)"
+}
+
+set testname "objcopy zlib-gnu compress debug sections with zlib-gabi"
+set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${compressedfile}.o ${copyfile}gabi.o"]
+if ![string match "" $got] then {
+ fail "objcopy ($testname)"
+ return
+}
+send_log "cmp ${compressedfile}gabi.o ${copyfile}gabi.o\n"
+verbose "cmp ${compressedfile}gabi.o ${copyfile}gabi.o"
+set src1 ${compressedfile}gabi.o
+set src2 ${copyfile}gabi.o
+set status [remote_exec build cmp "${src1} ${src2}"]
+set exec_output [lindex $status 1]
+set exec_output [prune_warnings $exec_output]
+if ![string match "" $exec_output] then {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail "objcopy ($testname)"
+} else {
+ pass "objcopy ($testname)"
+}
+
+set testname "objcopy zlib-gabi compress debug sections with zlib-gnu"
+set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${compressedfile}gabi.o ${copyfile}gnu.o"]
+if ![string match "" $got] then {
+ fail "objcopy ($testname)"
+ return
+}
+send_log "cmp ${compressedfile}gnu.o ${copyfile}gnu.o\n"
+verbose "cmp ${compressedfile}gnu.o ${copyfile}gnu.o"
+set src1 ${compressedfile}gnu.o
+set src2 ${copyfile}gnu.o
+set status [remote_exec build cmp "${src1} ${src2}"]
+set exec_output [lindex $status 1]
+set exec_output [prune_warnings $exec_output]
+if ![string match "" $exec_output] then {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail "objcopy ($testname)"
+} else {
+ pass "objcopy ($testname)"
+}
+
+set testname "objcopy compress debug sections 3 with zlib-gabi"
+set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${testfile3}.o ${copyfile}gabi.o"]
+if ![string match "" $got] then {
+ fail "objcopy ($testname)"
+ return
+}
+send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
+verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
+set src1 ${compressedfile3}gabi.o
+set src2 ${copyfile}gabi.o
+set status [remote_exec build cmp "${src1} ${src2}"]
+set exec_output [lindex $status 1]
+set exec_output [prune_warnings $exec_output]
+if ![string match "" $exec_output] then {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail "objcopy ($testname)"
+} else {
+ pass "objcopy ($testname)"
+}
+
+set testname "objcopy decompress compressed debug sections 3 with zlib-gabi"
+set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile3}gabi.o ${copyfile}gabi.o"]
+if ![string match "" $got] then {
+ fail "objcopy ($testname)"
+ return
+}
+send_log "cmp ${testfile3}.o ${copyfile}gabi.o\n"
+verbose "cmp ${testfile3}.o ${copyfile}gabi.o"
+set src1 ${testfile3}.o
+set src2 ${copyfile}gabi.o
+set status [remote_exec build cmp "${src1} ${src2}"]
+set exec_output [lindex $status 1]
+set exec_output [prune_warnings $exec_output]
+if ![string match "" $exec_output] then {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail "objcopy ($testname)"
+} else {
+ pass "objcopy ($testname)"
+}
+
+set testname "objcopy zlib-gnu compress debug sections 3 with zlib-gabi"
+set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${compressedfile3}.o ${copyfile}gabi.o"]
+if ![string match "" $got] then {
+ fail "objcopy ($testname)"
+ return
+}
+send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
+verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
+set src1 ${compressedfile3}gabi.o
+set src2 ${copyfile}gabi.o
+set status [remote_exec build cmp "${src1} ${src2}"]
+set exec_output [lindex $status 1]
+set exec_output [prune_warnings $exec_output]
+if ![string match "" $exec_output] then {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail "objcopy ($testname)"
+} else {
+ pass "objcopy ($testname)"
+}
+
+set testname "objcopy zlib-gabi compress debug sections 3 with zlib-gnu"
+set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${compressedfile3}gabi.o ${copyfile}gnu.o"]
+if ![string match "" $got] then {
+ fail "objcopy ($testname)"
+ return
+}
+send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
+verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
+set src1 ${compressedfile3}gnu.o
+set src2 ${copyfile}gnu.o
+set status [remote_exec build cmp "${src1} ${src2}"]
+set exec_output [lindex $status 1]
+set exec_output [prune_warnings $exec_output]
+if ![string match "" $exec_output] then {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail "objcopy ($testname)"
+} else {
+ pass "objcopy ($testname)"
+}
+
+set testname "objcopy zlib-gnu compress debug sections 3"
+set got [binutils_run $OBJCOPY "${compressedfile3}gnu.o ${copyfile}gnu.o"]
+if ![string match "" $got] then {
+ fail "objcopy ($testname)"
+ return
+}
+send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
+verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
+set src1 ${compressedfile3}gnu.o
+set src2 ${copyfile}gnu.o
+set status [remote_exec build cmp "${src1} ${src2}"]
+set exec_output [lindex $status 1]
+set exec_output [prune_warnings $exec_output]
+if ![string match "" $exec_output] then {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail "objcopy ($testname)"
+} else {
+ pass "objcopy ($testname)"
+}
+
+set testname "objcopy zlib-gnu compress debug sections 3"
+set got [binutils_run $OBJCOPY "${compressedfile3}gnu.o ${copyfile}gnu.o"]
+if ![string match "" $got] then {
+ fail "objcopy ($testname)"
+ return
+}
+send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
+verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
+set src1 ${compressedfile3}gnu.o
+set src2 ${copyfile}gnu.o
+set status [remote_exec build cmp "${src1} ${src2}"]
+set exec_output [lindex $status 1]
+set exec_output [prune_warnings $exec_output]
+if ![string match "" $exec_output] then {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail "objcopy ($testname)"
+} else {
+ pass "objcopy ($testname)"
+}
+
+set testname "objcopy decompress debug sections in archive with zlib-gabi"
+set got [binutils_run $OBJCOPY "--decompress-debug-sections ${libfile}gabi.a ${copyfile}gabi.a"]
+if ![string match "" $got] then {
+ fail "objcopy ($testname)"
+} else {
+ set got [remote_exec host "$READELF -S --wide ${copyfile}gabi.a" "" "/dev/null" "tmpdir/libdw2.out"]
+
+ if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+ fail "$testname (reason: unexpected output)"
+ send_log $got
+ send_log "\n"
+ }
+
+ if { [regexp_diff tmpdir/libdw2.out $srcdir/$subdir/libdw2.out] } then {
+ fail "$testname"
+ } else {
+ pass "$testname"
+ }
+}
+
+set testname "objcopy compress debug sections in archive with zlib-gabi"
+set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${copyfile}gabi.a ${compressedcopyfile}gabi.a"]
+if ![string match "" $got] then {
+ fail "objcopy ($testname)"
+} else {
+ set got [remote_exec host "$OBJDUMP -s -j .debug_info
+ ${compressedcopyfile}gabi.a" "" "/dev/null" "tmpdir/libdw2-compressedgabi.out"]
+
+ if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+ fail "$testname (reason: unexpected output)"
+ send_log $got
+ send_log "\n"
+ }
+
+ if { [regexp_diff tmpdir/libdw2-compressedgabi.out $srcdir/$subdir/libdw2-compressedgabi.out] } then {
+ fail "$testname"
+ } else {
+ pass "$testname"
+ }
+}
+
+set testname "objdump compress debug sections 3 with zlib-gabi"
+set got [remote_exec host "$OBJDUMP -W ${compressedfile3}gabi.o" "" "/dev/null" "objdump.out"]
+if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+ fail "$testname"
+ send_log "$got\n"
+}
+if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3.W] } then {
+ fail "$testname"
+} else {
+ pass "$testname"
+}
diff --git a/binutils/testsuite/binutils-all/dw2-3.rS b/binutils/testsuite/binutils-all/dw2-3.rS
new file mode 100644
index 0000000..f1637e9
--- /dev/null
+++ b/binutils/testsuite/binutils-all/dw2-3.rS
@@ -0,0 +1,3 @@
+#...
+ +\[[ 0-9]+\] .debug_info +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +C +0 +0 +1
+#pass
diff --git a/binutils/testsuite/binutils-all/dw2-3.rt b/binutils/testsuite/binutils-all/dw2-3.rt
new file mode 100644
index 0000000..f59cbaa
--- /dev/null
+++ b/binutils/testsuite/binutils-all/dw2-3.rt
@@ -0,0 +1,6 @@
+#...
+ +\[[ 0-9]+\] .debug_info
+ +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0 +0 +1
+ +\[0+800\]: COMPRESSED
+ +ZLIB, 0+9d, 1
+#pass
diff --git a/binutils/testsuite/binutils-all/libdw2-compressedgabi.out b/binutils/testsuite/binutils-all/libdw2-compressedgabi.out
new file mode 100644
index 0000000..3d395e4
--- /dev/null
+++ b/binutils/testsuite/binutils-all/libdw2-compressedgabi.out
@@ -0,0 +1,3 @@
+#...
+ .*ZLIB.*
+#pass