[llvm] r270541 - Revert r270540 "[llvm-dwarfdump] - Teach dwarfdump to decompress debug sections in zlib style."

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 02:44:44 PDT 2016


Author: grimar
Date: Tue May 24 04:44:44 2016
New Revision: 270541

URL: http://llvm.org/viewvc/llvm-project?rev=270541&view=rev
Log:
Revert r270540 "[llvm-dwarfdump] - Teach dwarfdump to decompress debug sections in zlib style."

it broked bot:
http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/5036

Removed:
    llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-zlibgnu.elf-x86-64
Modified:
    llvm/trunk/include/llvm/Object/COFF.h
    llvm/trunk/include/llvm/Object/ELFObjectFile.h
    llvm/trunk/include/llvm/Object/MachO.h
    llvm/trunk/include/llvm/Object/ObjectFile.h
    llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
    llvm/trunk/lib/Object/COFFObjectFile.cpp
    llvm/trunk/lib/Object/MachOObjectFile.cpp
    llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-zlib.cc
    llvm/trunk/test/DebugInfo/dwarfdump-zlib.test

Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=270541&r1=270540&r2=270541&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Tue May 24 04:44:44 2016
@@ -694,7 +694,6 @@ protected:
   std::error_code getSectionContents(DataRefImpl Sec,
                                      StringRef &Res) const override;
   uint64_t getSectionAlignment(DataRefImpl Sec) const override;
-  bool isSectionCompressed(DataRefImpl Sec) const override;
   bool isSectionText(DataRefImpl Sec) const override;
   bool isSectionData(DataRefImpl Sec) const override;
   bool isSectionBSS(DataRefImpl Sec) const override;

Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=270541&r1=270540&r2=270541&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Tue May 24 04:44:44 2016
@@ -222,7 +222,6 @@ protected:
   std::error_code getSectionContents(DataRefImpl Sec,
                                      StringRef &Res) const override;
   uint64_t getSectionAlignment(DataRefImpl Sec) const override;
-  bool isSectionCompressed(DataRefImpl Sec) const override;
   bool isSectionText(DataRefImpl Sec) const override;
   bool isSectionData(DataRefImpl Sec) const override;
   bool isSectionBSS(DataRefImpl Sec) const override;
@@ -585,11 +584,6 @@ uint64_t ELFObjectFile<ELFT>::getSection
 }
 
 template <class ELFT>
-bool ELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const {
-  return getSection(Sec)->sh_flags & ELF::SHF_COMPRESSED;
-}
-
-template <class ELFT>
 bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
   return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
 }

Modified: llvm/trunk/include/llvm/Object/MachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=270541&r1=270540&r2=270541&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachO.h (original)
+++ llvm/trunk/include/llvm/Object/MachO.h Tue May 24 04:44:44 2016
@@ -222,7 +222,6 @@ public:
   std::error_code getSectionContents(DataRefImpl Sec,
                                      StringRef &Res) const override;
   uint64_t getSectionAlignment(DataRefImpl Sec) const override;
-  bool isSectionCompressed(DataRefImpl Sec) const override;
   bool isSectionText(DataRefImpl Sec) const override;
   bool isSectionData(DataRefImpl Sec) const override;
   bool isSectionBSS(DataRefImpl Sec) const override;

Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=270541&r1=270540&r2=270541&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Tue May 24 04:44:44 2016
@@ -89,7 +89,6 @@ public:
   /// @brief Get the alignment of this section as the actual value (not log 2).
   uint64_t getAlignment() const;
 
-  bool isCompressed() const;
   bool isText() const;
   bool isData() const;
   bool isBSS() const;
@@ -215,7 +214,6 @@ protected:
   virtual std::error_code getSectionContents(DataRefImpl Sec,
                                              StringRef &Res) const = 0;
   virtual uint64_t getSectionAlignment(DataRefImpl Sec) const = 0;
-  virtual bool isSectionCompressed(DataRefImpl Sec) const = 0;
   virtual bool isSectionText(DataRefImpl Sec) const = 0;
   virtual bool isSectionData(DataRefImpl Sec) const = 0;
   virtual bool isSectionBSS(DataRefImpl Sec) const = 0;
@@ -382,10 +380,6 @@ inline uint64_t SectionRef::getAlignment
   return OwningObject->getSectionAlignment(SectionPimpl);
 }
 
-inline bool SectionRef::isCompressed() const {
-  return OwningObject->isSectionCompressed(SectionPimpl);
-}
-
 inline bool SectionRef::isText() const {
   return OwningObject->isSectionText(SectionPimpl);
 }

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=270541&r1=270540&r2=270541&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Tue May 24 04:44:44 2016
@@ -15,7 +15,6 @@
 #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Dwarf.h"
-#include "llvm/Support/ELF.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
@@ -591,8 +590,8 @@ DWARFContext::getInliningInfoForAddress(
   return InliningInfo;
 }
 
-static bool consumeCompressedGnuHeader(StringRef &data,
-                                       uint64_t &OriginalSize) {
+static bool consumeCompressedDebugSectionHeader(StringRef &data,
+                                                uint64_t &OriginalSize) {
   // Consume "ZLIB" prefix.
   if (!data.startswith("ZLIB"))
     return false;
@@ -607,50 +606,6 @@ static bool consumeCompressedGnuHeader(S
   return true;
 }
 
-static bool consumeCompressedZLibHeader(StringRef &Data, uint64_t &OriginalSize,
-                                        bool IsLE, bool Is64Bit) {
-  using namespace ELF;
-  uint64_t HdrSize = Is64Bit ? sizeof(Elf64_Chdr) : sizeof(Elf32_Chdr);
-  if (Data.size() < HdrSize)
-    return false;
-
-  DataExtractor Extractor(Data, IsLE, 0);
-  uint32_t Offset = 0;
-  if (Extractor.getUnsigned(&Offset, Is64Bit ? sizeof(Elf64_Word)
-                                             : sizeof(Elf32_Word)) !=
-      ELFCOMPRESS_ZLIB)
-    return false;
-
-  // Skip Elf64_Chdr::ch_reserved field.
-  if (Is64Bit)
-    Offset += sizeof(Elf64_Word);
-
-  OriginalSize = Extractor.getUnsigned(&Offset, Is64Bit ? sizeof(Elf64_Xword)
-                                                        : sizeof(Elf32_Word));
-  Data = Data.substr(HdrSize);
-  return true;
-}
-
-static bool tryDecompress(StringRef &Name, StringRef &Data,
-                          SmallString<32> &Out, bool ZLibStyle, bool IsLE,
-                          bool Is64Bit) {
-  if (!zlib::isAvailable())
-    return false;
-
-  uint64_t OriginalSize;
-  bool Result =
-      ZLibStyle ? consumeCompressedZLibHeader(Data, OriginalSize, IsLE, Is64Bit)
-                : consumeCompressedGnuHeader(Data, OriginalSize);
-
-  if (!Result || zlib::uncompress(Data, Out, OriginalSize) != zlib::StatusOK)
-    return false;
-
-  // gnu-style names are started from "z", consume that.
-  if (!ZLibStyle)
-    Name = Name.substr(1);
-  return true;
-}
-
 DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
     const LoadedObjectInfo *L)
     : IsLittleEndian(Obj.isLittleEndian()),
@@ -676,13 +631,20 @@ DWARFContextInMemory::DWARFContextInMemo
 
     name = name.substr(name.find_first_not_of("._")); // Skip . and _ prefixes.
 
-    bool ZLibStyleCompressed = Section.isCompressed();
-    if (ZLibStyleCompressed || name.startswith("zdebug_")) {
-      SmallString<32> Out;
-      if (!tryDecompress(name, data, Out, ZLibStyleCompressed, IsLittleEndian,
-                         AddressSize == 8))
+    // Check if debug info section is compressed with zlib.
+    if (name.startswith("zdebug_")) {
+      uint64_t OriginalSize;
+      if (!zlib::isAvailable() ||
+          !consumeCompressedDebugSectionHeader(data, OriginalSize))
         continue;
-      UncompressedSections.emplace_back(std::move(Out));
+      UncompressedSections.resize(UncompressedSections.size() + 1);
+      if (zlib::uncompress(data, UncompressedSections.back(), OriginalSize) !=
+          zlib::StatusOK) {
+        UncompressedSections.pop_back();
+        continue;
+      }
+      // Make data point to uncompressed section contents and save its contents.
+      name = name.substr(1);
       data = UncompressedSections.back();
     }
 

Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=270541&r1=270540&r2=270541&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Tue May 24 04:44:44 2016
@@ -292,10 +292,6 @@ uint64_t COFFObjectFile::getSectionAlign
   return Sec->getAlignment();
 }
 
-bool COFFObjectFile::isSectionCompressed(DataRefImpl Sec) const {
-  return false;
-}
-
 bool COFFObjectFile::isSectionText(DataRefImpl Ref) const {
   const coff_section *Sec = toSec(Ref);
   return Sec->Characteristics & COFF::IMAGE_SCN_CNT_CODE;

Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=270541&r1=270540&r2=270541&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Tue May 24 04:44:44 2016
@@ -653,10 +653,6 @@ uint64_t MachOObjectFile::getSectionAlig
   return uint64_t(1) << Align;
 }
 
-bool MachOObjectFile::isSectionCompressed(DataRefImpl Sec) const {
-  return false;
-}
-
 bool MachOObjectFile::isSectionText(DataRefImpl Sec) const {
   uint32_t Flags = getSectionFlags(this, Sec);
   return Flags & MachO::S_ATTR_PURE_INSTRUCTIONS;

Modified: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-zlib.cc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-zlib.cc?rev=270541&r1=270540&r2=270541&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-zlib.cc (original)
+++ llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-zlib.cc Tue May 24 04:44:44 2016
@@ -16,11 +16,9 @@ int main() {
   return f(2, 3);
 }
 
-// Built with Clang 3.9 and GNU gold (GNU Binutils for Ubuntu 2.26) 1.11:
+// Built with Clang 3.2 and ld.gold linker:
 // $ mkdir -p /tmp/dbginfo
 // $ cp dwarfdump-test-zlib.cc /tmp/dbginfo
 // $ cd /tmp/dbginfo
-// $ clang++ -g dwarfdump-test-zlib.cc -Wl,--compress-debug-sections=zlib -o dwarfdump-test-zlib.elf-x86-64
-// $ clang++ -g dwarfdump-test-zlib.cc -Wl,--compress-debug-sections=zlib-gnu -o dwarfdump-test-zlibgnu.elf-x86-64
-// llvm-readobj -sections can be used to see that outputs really contain the compressed sections, also output in both
-//   cases is slightly smaller, that is because of compression.
\ No newline at end of file
+// $ clang++ -g dwarfdump-test-zlib.cc -Wl,--compress-debug-sections=zlib \
+//   -o <output>

Removed: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-zlibgnu.elf-x86-64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-zlibgnu.elf-x86-64?rev=270540&view=auto
==============================================================================
Binary file - no diff available.

Modified: llvm/trunk/test/DebugInfo/dwarfdump-zlib.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-zlib.test?rev=270541&r1=270540&r2=270541&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/dwarfdump-zlib.test (original)
+++ llvm/trunk/test/DebugInfo/dwarfdump-zlib.test Tue May 24 04:44:44 2016
@@ -1,12 +1,6 @@
 REQUIRES: zlib
 
 RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test-zlib.elf-x86-64 | FileCheck %s
-RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test-zlibgnu.elf-x86-64 | FileCheck %s
 
 CHECK: .debug_abbrev contents
-
-// Dump content of a little section to check that both zlib and zlib gnu styles do
-// the decompression correctly and result is the same. This and above also checks
-// that sections names are properly shown in zlib-gnu style (without additional 'z' prefix).
 CHECK: .debug_info contents
-CHECK: 0x00000000: Compile Unit: length = 0x00000144 version = 0x0004 abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x00000148)




More information about the llvm-commits mailing list