Extend --compress-debug-sections in gold
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 12 Jul 2015 17:56:41 +0000 (10:56 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 12 Jul 2015 17:56:58 +0000 (10:56 -0700)
This patch extends --compress-debug-sections= with [zlib-gnu|zlib-gabi]
in gold.

PR gold/18322
* compressed_output.cc (zlib_compress): Add argument for
compression header size.  Set header size to compression header
size if it isn't 0.  Don't write out the zlib header here.
(Output_compressed_section::set_final_data_size): Support
zlib-gnu and zlib-gabi compressions.  Pass compression header
size to zlib_compress and write out compression header.  Set
the SHF_COMPRESSED bit for zlib-gabi compression.  Otherwise
clear the SHF_COMPRESSED bit
* options.h (compress_debug_sections): Add zlib-gnu and
zlib-gabi.
* output.h (Output_section::set_flags): New.
* testsuite/Makefile.am (check_PROGRAMS): Add
flagstest_compress_debug_sections_none,
flagstest_compress_debug_sections_gnu and
flagstest_compress_debug_sections_gabi.
(check_DATA): Add flagstest_compress_debug_sections_none.stdout.
flagstest_compress_debug_sections.stdout,
flagstest_compress_debug_sections.cmp,
flagstest_compress_debug_sections.check,
flagstest_compress_debug_sections_gnu.stdout,
flagstest_compress_debug_sections_gnu.cmp,
flagstest_compress_debug_sections_gnu.check,
flagstest_compress_debug_sections_gabi.stdout,
flagstest_compress_debug_sections_gabi.cmp and
flagstest_compress_debug_sections_gabi.check.
(flagstest_compress_debug_sections_none): New.
(flagstest_compress_debug_sections_none.stdout): Likewise.
(flagstest_compress_debug_sections.stdout): Likewise.
(flagstest_compress_debug_sections.check): Likewise.
(flagstest_compress_debug_sections.cmp): Likewise.
(flagstest_compress_debug_sections_gnu): Likewise.
(flagstest_compress_debug_sections_gnu.stdout): Likewise.
(flagstest_compress_debug_sections_gnu.check): Likewise.
(flagstest_compress_debug_sections_gnu.cmp): Likewise.
(flagstest_compress_debug_sections_gabi): Likewise.
(flagstest_compress_debug_sections_gabi.stdout): Likewise.
(flagstest_compress_debug_sections_gnu.check): Likewise.
(flagstest_compress_debug_sections_gnu.cmp): Likewise.
* testsuite/Makefile.in: Regenerated.

gold/ChangeLog
gold/compressed_output.cc
gold/options.h
gold/output.h
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in

index 93b363ae60c1c6692354019a8edf51ded4826915..a8c2507edb7796faff39166cc7783489a8537baf 100644 (file)
@@ -1,3 +1,46 @@
+2015-07-12  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gold/18322
+       * compressed_output.cc (zlib_compress): Add argument for
+       compression header size.  Set header size to compression header
+       size if it isn't 0.  Don't write out the zlib header here.
+       (Output_compressed_section::set_final_data_size): Support
+       zlib-gnu and zlib-gabi compressions.  Pass compression header
+       size to zlib_compress and write out compression header.  Set
+       the SHF_COMPRESSED bit for zlib-gabi compression.  Otherwise
+       clear the SHF_COMPRESSED bit
+       * options.h (compress_debug_sections): Add zlib-gnu and
+       zlib-gabi.
+       * output.h (Output_section::set_flags): New.
+       * testsuite/Makefile.am (check_PROGRAMS): Add
+       flagstest_compress_debug_sections_none,
+       flagstest_compress_debug_sections_gnu and
+       flagstest_compress_debug_sections_gabi.
+       (check_DATA): Add flagstest_compress_debug_sections_none.stdout.
+       flagstest_compress_debug_sections.stdout,
+       flagstest_compress_debug_sections.cmp,
+       flagstest_compress_debug_sections.check,
+       flagstest_compress_debug_sections_gnu.stdout,
+       flagstest_compress_debug_sections_gnu.cmp,
+       flagstest_compress_debug_sections_gnu.check,
+       flagstest_compress_debug_sections_gabi.stdout,
+       flagstest_compress_debug_sections_gabi.cmp and
+       flagstest_compress_debug_sections_gabi.check.
+       (flagstest_compress_debug_sections_none): New.
+       (flagstest_compress_debug_sections_none.stdout): Likewise.
+       (flagstest_compress_debug_sections.stdout): Likewise.
+       (flagstest_compress_debug_sections.check): Likewise.
+       (flagstest_compress_debug_sections.cmp): Likewise.
+       (flagstest_compress_debug_sections_gnu): Likewise.
+       (flagstest_compress_debug_sections_gnu.stdout): Likewise.
+       (flagstest_compress_debug_sections_gnu.check): Likewise.
+       (flagstest_compress_debug_sections_gnu.cmp): Likewise.
+       (flagstest_compress_debug_sections_gabi): Likewise.
+       (flagstest_compress_debug_sections_gabi.stdout): Likewise.
+       (flagstest_compress_debug_sections_gnu.check): Likewise.
+       (flagstest_compress_debug_sections_gnu.cmp): Likewise.
+       * testsuite/Makefile.in: Regenerated.
+
 2015-07-12  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR gold/18321
index 02d78212daf88f8b1225ff3f23792860db1aac10..263033097426ea7ab8cfe3a9cc9488816ca5b40b 100644 (file)
@@ -39,12 +39,12 @@ namespace gold
 // order.
 
 static bool
-zlib_compress(const unsigned char* uncompressed_data,
+zlib_compress(int header_size,
+              const unsigned char* uncompressed_data,
               unsigned long uncompressed_size,
               unsigned char** compressed_data,
               unsigned long* compressed_size)
 {
-  const int header_size = 12;
   *compressed_size = uncompressed_size + uncompressed_size / 1000 + 128;
   *compressed_data = new unsigned char[*compressed_size + header_size];
 
@@ -61,9 +61,6 @@ zlib_compress(const unsigned char* uncompressed_data,
                      compress_level);
   if (rc == Z_OK)
     {
-      memcpy(*compressed_data, "ZLIB", 4);
-      elfcpp::Swap_unaligned<64, true>::writeval(*compressed_data + 4,
-                                                uncompressed_size);
       *compressed_size += header_size;
       return true;
     }
@@ -233,14 +230,86 @@ Output_compressed_section::set_final_data_size()
   this->write_to_postprocessing_buffer();
 
   bool success = false;
+  enum { none, gnu_zlib, gabi_zlib } compress;
+  int compression_header_size = 12;
+  const int size = parameters->target().get_size();
   if (strcmp(this->options_->compress_debug_sections(), "zlib") == 0)
-    success = zlib_compress(uncompressed_data, uncompressed_size,
-                            &this->data_, &compressed_size);
+    compress = gnu_zlib;
+  else if (strcmp(this->options_->compress_debug_sections(), "zlib-gnu") == 0)
+    compress = gnu_zlib;
+  else if (strcmp(this->options_->compress_debug_sections(), "zlib-gabi") == 0)
+    {
+      compress = gabi_zlib;
+      if (size == 32)
+       compression_header_size = elfcpp::Elf_sizes<32>::chdr_size;
+      else if (size == 64)
+       compression_header_size = elfcpp::Elf_sizes<64>::chdr_size;
+      else
+       gold_unreachable();
+    }
+  else
+    compress = none;
+  if (compress != none)
+    success = zlib_compress(compression_header_size, uncompressed_data,
+                           uncompressed_size, &this->data_,
+                           &compressed_size);
   if (success)
     {
-      // This converts .debug_foo to .zdebug_foo
-      this->new_section_name_ = std::string(".z") + (this->name() + 1);
-      this->set_name(this->new_section_name_.c_str());
+      elfcpp::Elf_Xword flags = this->flags();
+      if (compress == gabi_zlib)
+       {
+         // Set the SHF_COMPRESSED bit.
+         flags |= elfcpp::SHF_COMPRESSED;
+         const bool is_big_endian = parameters->target().is_big_endian();
+         uint64_t addralign = this->addralign();
+         if (size == 32)
+           {
+             if (is_big_endian)
+               {
+                 elfcpp::Chdr_write<32, true> chdr(this->data_);
+                 chdr.put_ch_type(elfcpp::ELFCOMPRESS_ZLIB);
+                 chdr.put_ch_size(uncompressed_size);
+                 chdr.put_ch_addralign(addralign);
+               }
+             else
+               {
+                 elfcpp::Chdr_write<32, false> chdr(this->data_);
+                 chdr.put_ch_type(elfcpp::ELFCOMPRESS_ZLIB);
+                 chdr.put_ch_size(uncompressed_size);
+                 chdr.put_ch_addralign(addralign);
+               }
+           }
+         else if (size == 64)
+           {
+             if (is_big_endian)
+               {
+                 elfcpp::Chdr_write<64, true> chdr(this->data_);
+                 chdr.put_ch_type(elfcpp::ELFCOMPRESS_ZLIB);
+                 chdr.put_ch_size(uncompressed_size);
+                 chdr.put_ch_addralign(addralign);
+               }
+             else
+               {
+                 elfcpp::Chdr_write<64, false> chdr(this->data_);
+                 chdr.put_ch_type(elfcpp::ELFCOMPRESS_ZLIB);
+                 chdr.put_ch_size(uncompressed_size);
+                 chdr.put_ch_addralign(addralign);
+               }
+           }
+         else
+           gold_unreachable();
+       }
+      else
+       {
+         // Write out the zlib header.
+         memcpy(this->data_, "ZLIB", 4);
+         elfcpp::Swap_unaligned<64, true>::writeval(this->data_ + 4,
+                                                    uncompressed_size);
+         // This converts .debug_foo to .zdebug_foo
+         this->new_section_name_ = std::string(".z") + (this->name() + 1);
+         this->set_name(this->new_section_name_.c_str());
+       }
+      this->set_flags(flags);
       this->set_data_size(compressed_size);
     }
   else
index 455a09d3dd95a5b0702c966e48dceeb0e661b4bb..f4da1280a6507e9fefbe063ea2c29a2081a13d6e 100644 (file)
@@ -697,8 +697,8 @@ class General_options
 
   DEFINE_enum(compress_debug_sections, options::TWO_DASHES, '\0', "none",
              N_("Compress .debug_* sections in the output file"),
-             ("[none,zlib]"),
-             {"none", "zlib"});
+             ("[none,zlib,zlib-gnu,zlib-gabi]"),
+             {"none", "zlib", "zlib-gnu", "zlib-gabi"});
 
   DEFINE_bool(copy_dt_needed_entries, options::TWO_DASHES, '\0', false,
              N_("Not supported"),
index be729655833dfe7191ba9fb55380b42bdccab7a9..c7ad54e54a2c9af31e9f000a814dfe1f3ca60bf8 100644 (file)
@@ -3100,6 +3100,11 @@ class Output_section : public Output_data
   void
   update_flags_for_input_section(elfcpp::Elf_Xword flags);
 
+  // Set the output section flags.
+  void
+  set_flags(elfcpp::Elf_Xword flags)
+  { this->flags_ = flags; }
+
   // Return the entsize field.
   uint64_t
   entsize() const
index 9c28c9ae15de0a9fb795260f721344bcad73aa8e..d2f466825beb578cac268ff905b3736cead3cae8 100644 (file)
@@ -1319,8 +1319,22 @@ flagstest_o_specialfile: flagstest_debug.o gcctestdir/ld
        chmod a+x $@
        test -s $@
 
-# Test --compress-debug-sections.  FIXME: check we actually compress.
+# Test --compress-debug-sections.
+check_PROGRAMS += flagstest_compress_debug_sections_none
+check_DATA += flagstest_compress_debug_sections_none.stdout
+flagstest_compress_debug_sections_none: flagstest_debug.o gcctestdir/ld
+       $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=none
+       test -s $@
+
+# Dump DWARF debug sections.
+flagstest_compress_debug_sections_none.stdout: flagstest_compress_debug_sections_none
+       $(TEST_READELF) -w $< > $@.tmp
+       mv -f $@.tmp $@
+
 check_PROGRAMS += flagstest_compress_debug_sections
+check_DATA += flagstest_compress_debug_sections.stdout \
+             flagstest_compress_debug_sections.cmp \
+             flagstest_compress_debug_sections.check
 flagstest_compress_debug_sections: flagstest_debug.o gcctestdir/ld
        $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=zlib
        test -s $@
@@ -1334,6 +1348,73 @@ flagstest_compress_debug_sections_and_build_id_tree: flagstest_debug.o gcctestdi
                -Wl,--build-id-min-file-size-for-treehash=0
        test -s $@
 
+# Dump compressed DWARF debug sections.
+flagstest_compress_debug_sections.stdout: flagstest_compress_debug_sections
+       $(TEST_READELF) -w $< | sed -e "s/.zdebug_/.debug_/" > $@.tmp
+       mv -f $@.tmp $@
+
+# Check there are compressed DWARF .zdebug_* sections.
+flagstest_compress_debug_sections.check: flagstest_compress_debug_sections
+       $(TEST_READELF) -SW $< | grep ".zdebug_" > $@.tmp
+       mv -f $@.tmp $@
+
+# Compare DWARF debug info.
+flagstest_compress_debug_sections.cmp: flagstest_compress_debug_sections.stdout \
+       flagstest_compress_debug_sections_none.stdout
+       cmp flagstest_compress_debug_sections.stdout \
+               flagstest_compress_debug_sections_none.stdout > $@.tmp
+       mv -f $@.tmp $@
+
+check_PROGRAMS += flagstest_compress_debug_sections_gnu
+check_DATA += flagstest_compress_debug_sections_gnu.stdout \
+             flagstest_compress_debug_sections_gnu.cmp \
+             flagstest_compress_debug_sections_gnu.check
+flagstest_compress_debug_sections_gnu: flagstest_debug.o gcctestdir/ld
+       $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=zlib-gnu
+       test -s $@
+
+# Dump compressed DWARF debug sections.
+flagstest_compress_debug_sections_gnu.stdout: flagstest_compress_debug_sections_gnu
+       $(TEST_READELF) -w $< | sed -e "s/.zdebug_/.debug_/" > $@.tmp
+       mv -f $@.tmp $@
+
+# Check there are compressed DWARF .zdebug_* sections.
+flagstest_compress_debug_sections_gnu.check: flagstest_compress_debug_sections_gnu
+       $(TEST_READELF) -SW $< | grep ".zdebug_" > $@.tmp
+       mv -f $@.tmp $@
+
+# Compare DWARF debug info.
+flagstest_compress_debug_sections_gnu.cmp: flagstest_compress_debug_sections_gnu.stdout \
+       flagstest_compress_debug_sections_none.stdout
+       cmp flagstest_compress_debug_sections_gnu.stdout \
+               flagstest_compress_debug_sections_none.stdout > $@.tmp
+       mv -f $@.tmp $@
+
+check_PROGRAMS += flagstest_compress_debug_sections_gabi
+check_DATA += flagstest_compress_debug_sections_gabi.stdout \
+             flagstest_compress_debug_sections_gabi.cmp \
+             flagstest_compress_debug_sections_gabi.check
+flagstest_compress_debug_sections_gabi: flagstest_debug.o gcctestdir/ld
+       $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=zlib-gabi
+       test -s $@
+
+# Dump compressed DWARF debug sections.
+flagstest_compress_debug_sections_gabi.stdout: flagstest_compress_debug_sections_gabi
+       $(TEST_READELF) -w $< > $@.tmp
+       mv -f $@.tmp $@
+
+# Check there are compressed DWARF .debug_* sections.
+flagstest_compress_debug_sections_gabi.check: flagstest_compress_debug_sections_gabi
+       $(TEST_READELF) -tW $< | grep "COMPRESSED" > $@.tmp
+       mv -f $@.tmp $@
+
+# Compare DWARF debug info.
+flagstest_compress_debug_sections_gabi.cmp: flagstest_compress_debug_sections_gabi.stdout \
+       flagstest_compress_debug_sections_none.stdout
+       cmp flagstest_compress_debug_sections_gabi.stdout \
+               flagstest_compress_debug_sections_none.stdout > $@.tmp
+       mv -f $@.tmp $@
+
 # The specialfile output has a tricky case when we also compress debug
 # sections, because it requires output-file resizing.
 check_PROGRAMS += flagstest_o_specialfile_and_compress_debug_sections
index 1131512f52fdf6f613fa5607247fb0b67a0ea255..1c336c6a78f21b8bc522ec6ccb194b5ca7c74e75 100644 (file)
@@ -226,7 +226,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
 
 # Test -o when emitting to a special file (such as something in /dev).
 
-# Test --compress-debug-sections.  FIXME: check we actually compress.
+# Test --compress-debug-sections.
 
 # Test --compress-debug-sections with --build-id=tree.
 
@@ -246,8 +246,11 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ many_sections_r_test initpri1 \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ initpri2 initpri3a \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_none \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_and_build_id_tree \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gnu \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gabi \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile_and_compress_debug_sections \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_ttext_1 ver_test \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_2 ver_test_6 ver_test_8 \
@@ -352,6 +355,16 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_so.err \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_ndebug.err \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ undef_symbol.err \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_none.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections.cmp \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections.check \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gnu.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gnu.cmp \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gnu.check \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gabi.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gabi.cmp \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gabi.check \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_ttext_2 \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_1.syms ver_test_2.syms \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_4.syms ver_test_5.syms \
@@ -907,8 +920,11 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ initpri2$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ initpri3a$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_none$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_and_build_id_tree$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gnu$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gabi$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile_and_compress_debug_sections$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_ttext_1$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test$(EXEEXT) \
@@ -1199,6 +1215,33 @@ flagstest_compress_debug_sections_and_build_id_tree_DEPENDENCIES =  \
        libgoldtest.a ../libgold.a ../../libiberty/libiberty.a \
        $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+flagstest_compress_debug_sections_gabi_SOURCES =  \
+       flagstest_compress_debug_sections_gabi.c
+flagstest_compress_debug_sections_gabi_OBJECTS =  \
+       flagstest_compress_debug_sections_gabi.$(OBJEXT)
+flagstest_compress_debug_sections_gabi_LDADD = $(LDADD)
+flagstest_compress_debug_sections_gabi_DEPENDENCIES = libgoldtest.a \
+       ../libgold.a ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1)
+flagstest_compress_debug_sections_gnu_SOURCES =  \
+       flagstest_compress_debug_sections_gnu.c
+flagstest_compress_debug_sections_gnu_OBJECTS =  \
+       flagstest_compress_debug_sections_gnu.$(OBJEXT)
+flagstest_compress_debug_sections_gnu_LDADD = $(LDADD)
+flagstest_compress_debug_sections_gnu_DEPENDENCIES = libgoldtest.a \
+       ../libgold.a ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1)
+flagstest_compress_debug_sections_none_SOURCES =  \
+       flagstest_compress_debug_sections_none.c
+flagstest_compress_debug_sections_none_OBJECTS =  \
+       flagstest_compress_debug_sections_none.$(OBJEXT)
+flagstest_compress_debug_sections_none_LDADD = $(LDADD)
+flagstest_compress_debug_sections_none_DEPENDENCIES = libgoldtest.a \
+       ../libgold.a ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1)
 flagstest_o_specialfile_SOURCES = flagstest_o_specialfile.c
 flagstest_o_specialfile_OBJECTS = flagstest_o_specialfile.$(OBJEXT)
 flagstest_o_specialfile_LDADD = $(LDADD)
@@ -2051,6 +2094,9 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \
        $(exclude_libs_test_SOURCES) \
        flagstest_compress_debug_sections.c \
        flagstest_compress_debug_sections_and_build_id_tree.c \
+       flagstest_compress_debug_sections_gabi.c \
+       flagstest_compress_debug_sections_gnu.c \
+       flagstest_compress_debug_sections_none.c \
        flagstest_o_specialfile.c \
        flagstest_o_specialfile_and_compress_debug_sections.c \
        flagstest_o_ttext_1.c icf_virtual_function_folding_test.c \
@@ -3096,6 +3142,24 @@ exclude_libs_test$(EXEEXT): $(exclude_libs_test_OBJECTS) $(exclude_libs_test_DEP
 @NATIVE_LINKER_FALSE@flagstest_compress_debug_sections_and_build_id_tree$(EXEEXT): $(flagstest_compress_debug_sections_and_build_id_tree_OBJECTS) $(flagstest_compress_debug_sections_and_build_id_tree_DEPENDENCIES) 
 @NATIVE_LINKER_FALSE@  @rm -f flagstest_compress_debug_sections_and_build_id_tree$(EXEEXT)
 @NATIVE_LINKER_FALSE@  $(LINK) $(flagstest_compress_debug_sections_and_build_id_tree_OBJECTS) $(flagstest_compress_debug_sections_and_build_id_tree_LDADD) $(LIBS)
+@GCC_FALSE@flagstest_compress_debug_sections_gabi$(EXEEXT): $(flagstest_compress_debug_sections_gabi_OBJECTS) $(flagstest_compress_debug_sections_gabi_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f flagstest_compress_debug_sections_gabi$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(flagstest_compress_debug_sections_gabi_OBJECTS) $(flagstest_compress_debug_sections_gabi_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@flagstest_compress_debug_sections_gabi$(EXEEXT): $(flagstest_compress_debug_sections_gabi_OBJECTS) $(flagstest_compress_debug_sections_gabi_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f flagstest_compress_debug_sections_gabi$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(flagstest_compress_debug_sections_gabi_OBJECTS) $(flagstest_compress_debug_sections_gabi_LDADD) $(LIBS)
+@GCC_FALSE@flagstest_compress_debug_sections_gnu$(EXEEXT): $(flagstest_compress_debug_sections_gnu_OBJECTS) $(flagstest_compress_debug_sections_gnu_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f flagstest_compress_debug_sections_gnu$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(flagstest_compress_debug_sections_gnu_OBJECTS) $(flagstest_compress_debug_sections_gnu_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@flagstest_compress_debug_sections_gnu$(EXEEXT): $(flagstest_compress_debug_sections_gnu_OBJECTS) $(flagstest_compress_debug_sections_gnu_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f flagstest_compress_debug_sections_gnu$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(flagstest_compress_debug_sections_gnu_OBJECTS) $(flagstest_compress_debug_sections_gnu_LDADD) $(LIBS)
+@GCC_FALSE@flagstest_compress_debug_sections_none$(EXEEXT): $(flagstest_compress_debug_sections_none_OBJECTS) $(flagstest_compress_debug_sections_none_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f flagstest_compress_debug_sections_none$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(flagstest_compress_debug_sections_none_OBJECTS) $(flagstest_compress_debug_sections_none_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@flagstest_compress_debug_sections_none$(EXEEXT): $(flagstest_compress_debug_sections_none_OBJECTS) $(flagstest_compress_debug_sections_none_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f flagstest_compress_debug_sections_none$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(flagstest_compress_debug_sections_none_OBJECTS) $(flagstest_compress_debug_sections_none_LDADD) $(LIBS)
 @GCC_FALSE@flagstest_o_specialfile$(EXEEXT): $(flagstest_o_specialfile_OBJECTS) $(flagstest_o_specialfile_DEPENDENCIES) 
 @GCC_FALSE@    @rm -f flagstest_o_specialfile$(EXEEXT)
 @GCC_FALSE@    $(LINK) $(flagstest_o_specialfile_OBJECTS) $(flagstest_o_specialfile_LDADD) $(LIBS)
@@ -3847,6 +3911,9 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exclude_libs_test.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_compress_debug_sections.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_compress_debug_sections_and_build_id_tree.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_compress_debug_sections_gabi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_compress_debug_sections_gnu.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_compress_debug_sections_none.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_o_specialfile.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_o_specialfile_and_compress_debug_sections.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_o_ttext_1.Po@am__quote@
@@ -4610,10 +4677,16 @@ initpri3a.log: initpri3a$(EXEEXT)
        @p='initpri3a$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 flagstest_o_specialfile.log: flagstest_o_specialfile$(EXEEXT)
        @p='flagstest_o_specialfile$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+flagstest_compress_debug_sections_none.log: flagstest_compress_debug_sections_none$(EXEEXT)
+       @p='flagstest_compress_debug_sections_none$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 flagstest_compress_debug_sections.log: flagstest_compress_debug_sections$(EXEEXT)
        @p='flagstest_compress_debug_sections$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 flagstest_compress_debug_sections_and_build_id_tree.log: flagstest_compress_debug_sections_and_build_id_tree$(EXEEXT)
        @p='flagstest_compress_debug_sections_and_build_id_tree$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+flagstest_compress_debug_sections_gnu.log: flagstest_compress_debug_sections_gnu$(EXEEXT)
+       @p='flagstest_compress_debug_sections_gnu$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+flagstest_compress_debug_sections_gabi.log: flagstest_compress_debug_sections_gabi$(EXEEXT)
+       @p='flagstest_compress_debug_sections_gabi$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 flagstest_o_specialfile_and_compress_debug_sections.log: flagstest_o_specialfile_and_compress_debug_sections$(EXEEXT)
        @p='flagstest_o_specialfile_and_compress_debug_sections$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 flagstest_o_ttext_1.log: flagstest_o_ttext_1$(EXEEXT)
@@ -5522,6 +5595,14 @@ uninstall-am:
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< 2>&1 | cat > $@
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ chmod a+x $@
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ test -s $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections_none: flagstest_debug.o gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=none
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ test -s $@
+
+# Dump DWARF debug sections.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections_none.stdout: flagstest_compress_debug_sections_none
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -w $< > $@.tmp
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ mv -f $@.tmp $@
 @GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections: flagstest_debug.o gcctestdir/ld
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=zlib
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ test -s $@
@@ -5531,6 +5612,63 @@ uninstall-am:
 @GCC_TRUE@@NATIVE_LINKER_TRUE@         -Wl,--build-id-chunk-size-for-treehash=4096 \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@         -Wl,--build-id-min-file-size-for-treehash=0
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ test -s $@
+
+# Dump compressed DWARF debug sections.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections.stdout: flagstest_compress_debug_sections
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -w $< | sed -e "s/.zdebug_/.debug_/" > $@.tmp
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ mv -f $@.tmp $@
+
+# Check there are compressed DWARF .zdebug_* sections.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections.check: flagstest_compress_debug_sections
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SW $< | grep ".zdebug_" > $@.tmp
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ mv -f $@.tmp $@
+
+# Compare DWARF debug info.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections.cmp: flagstest_compress_debug_sections.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_none.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ cmp flagstest_compress_debug_sections.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@         flagstest_compress_debug_sections_none.stdout > $@.tmp
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ mv -f $@.tmp $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections_gnu: flagstest_debug.o gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=zlib-gnu
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ test -s $@
+
+# Dump compressed DWARF debug sections.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections_gnu.stdout: flagstest_compress_debug_sections_gnu
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -w $< | sed -e "s/.zdebug_/.debug_/" > $@.tmp
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ mv -f $@.tmp $@
+
+# Check there are compressed DWARF .zdebug_* sections.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections_gnu.check: flagstest_compress_debug_sections_gnu
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SW $< | grep ".zdebug_" > $@.tmp
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ mv -f $@.tmp $@
+
+# Compare DWARF debug info.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections_gnu.cmp: flagstest_compress_debug_sections_gnu.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_none.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ cmp flagstest_compress_debug_sections_gnu.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@         flagstest_compress_debug_sections_none.stdout > $@.tmp
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ mv -f $@.tmp $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections_gabi: flagstest_debug.o gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=zlib-gabi
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ test -s $@
+
+# Dump compressed DWARF debug sections.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections_gabi.stdout: flagstest_compress_debug_sections_gabi
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -w $< > $@.tmp
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ mv -f $@.tmp $@
+
+# Check there are compressed DWARF .debug_* sections.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections_gabi.check: flagstest_compress_debug_sections_gabi
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -tW $< | grep "COMPRESSED" > $@.tmp
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ mv -f $@.tmp $@
+
+# Compare DWARF debug info.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections_gabi.cmp: flagstest_compress_debug_sections_gabi.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_none.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ cmp flagstest_compress_debug_sections_gabi.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@         flagstest_compress_debug_sections_none.stdout > $@.tmp
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ mv -f $@.tmp $@
 @GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_o_specialfile_and_compress_debug_sections: flagstest_debug.o \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@         gcctestdir/ld
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< -Wl,--compress-debug-sections=zlib 2>&1 | cat > $@