[Lldb-commits] [lldb] r365654 - ObjectFileELF: Add support for gnu-style compressed sections

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 10 09:10:44 PDT 2019


Author: labath
Date: Wed Jul 10 09:10:43 2019
New Revision: 365654

URL: http://llvm.org/viewvc/llvm-project?rev=365654&view=rev
Log:
ObjectFileELF: Add support for gnu-style compressed sections

With this style, a compressed section is indicated by a "z" in the section
name, instead of a section header flag. This patch consists of two small tweaks:
- use an llvm Decompressor method in order to properly detect compressed sections
- make sure we recognise .zdebug_info (and friends) when classifying section types.

Added:
    lldb/trunk/lit/SymbolFile/DWARF/gnu-style-compression.cpp
Modified:
    lldb/trunk/lit/Modules/ELF/compressed-sections.yaml
    lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Modified: lldb/trunk/lit/Modules/ELF/compressed-sections.yaml
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/compressed-sections.yaml?rev=365654&r1=365653&r2=365654&view=diff
==============================================================================
--- lldb/trunk/lit/Modules/ELF/compressed-sections.yaml (original)
+++ lldb/trunk/lit/Modules/ELF/compressed-sections.yaml Wed Jul 10 09:10:43 2019
@@ -16,14 +16,18 @@ Sections:
     Type:            SHT_PROGBITS
     Flags:           [ SHF_COMPRESSED ]
     Content:         deadbeefbaadf00d
+  - Name:            .zdebug_info
+    Type:            SHT_PROGBITS
+    Content:         5A4C49420000000000000008789c5330700848286898000009c802c1
 
 # CHECK: Name: .hello_elf
 # CHECK-NEXT: Type: regular
 # CHECK: VM address: 0
 # CHECK-NEXT: VM size: 0
 # CHECK-NEXT: File size: 28
-# CHECK-NEXT: Data:
+# CHECK-NEXT: Data: (
 # CHECK-NEXT: 20304050 60708090
+# CHECK-NEXT: )
 
 # CHECK: Name: .bogus
 # CHECK-NEXT: Type: regular
@@ -31,3 +35,10 @@ Sections:
 # CHECK-NEXT: VM size: 0
 # CHECK-NEXT: File size: 8
 # CHECK-NEXT: Data: ()
+
+# CHECK: Name: .zdebug_info
+# CHECK: dwarf-info
+# CHECK: File size: 28
+# CHECK: Data: (
+# CHECK-NEXT: 20304050 60708090
+# CHECK-NEXT: )

Added: lldb/trunk/lit/SymbolFile/DWARF/gnu-style-compression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/gnu-style-compression.cpp?rev=365654&view=auto
==============================================================================
--- lldb/trunk/lit/SymbolFile/DWARF/gnu-style-compression.cpp (added)
+++ lldb/trunk/lit/SymbolFile/DWARF/gnu-style-compression.cpp Wed Jul 10 09:10:43 2019
@@ -0,0 +1,14 @@
+// REQUIRES: zlib
+
+// RUN: %clang %s -target x86_64-pc-linux -g -gsplit-dwarf -c -o %t \
+// RUN:   -Wa,--compress-debug-sections=zlib-gnu
+// RUN: %lldb %t -o "target var s a" -b | FileCheck %s
+
+// CHECK: (const short) s = 47
+// CHECK: (const A) a = (a = 42)
+
+struct A {
+  long a = 42;
+};
+extern constexpr short s = 47;
+extern constexpr A a{};

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=365654&r1=365653&r2=365654&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Wed Jul 10 09:10:43 2019
@@ -1674,38 +1674,40 @@ lldb::user_id_t ObjectFileELF::GetSectio
 }
 
 static SectionType GetSectionTypeFromName(llvm::StringRef Name) {
+  if (Name.consume_front(".debug_") || Name.consume_front(".zdebug_")) {
+    return llvm::StringSwitch<SectionType>(Name)
+        .Case("abbrev", eSectionTypeDWARFDebugAbbrev)
+        .Case("abbrev.dwo", eSectionTypeDWARFDebugAbbrevDwo)
+        .Case("addr", eSectionTypeDWARFDebugAddr)
+        .Case("aranges", eSectionTypeDWARFDebugAranges)
+        .Case("cu_index", eSectionTypeDWARFDebugCuIndex)
+        .Case("frame", eSectionTypeDWARFDebugFrame)
+        .Case("info", eSectionTypeDWARFDebugInfo)
+        .Case("info.dwo", eSectionTypeDWARFDebugInfoDwo)
+        .Cases("line", "line.dwo", eSectionTypeDWARFDebugLine)
+        .Cases("line_str", "line_str.dwo", eSectionTypeDWARFDebugLineStr)
+        .Cases("loc", "loc.dwo", eSectionTypeDWARFDebugLoc)
+        .Cases("loclists", "loclists.dwo", eSectionTypeDWARFDebugLocLists)
+        .Case("macinfo", eSectionTypeDWARFDebugMacInfo)
+        .Cases("macro", "macro.dwo", eSectionTypeDWARFDebugMacro)
+        .Case("names", eSectionTypeDWARFDebugNames)
+        .Case("pubnames", eSectionTypeDWARFDebugPubNames)
+        .Case("pubtypes", eSectionTypeDWARFDebugPubTypes)
+        .Case("ranges", eSectionTypeDWARFDebugRanges)
+        .Case("rnglists", eSectionTypeDWARFDebugRngLists)
+        .Case("str", eSectionTypeDWARFDebugStr)
+        .Case("str.dwo", eSectionTypeDWARFDebugStrDwo)
+        .Case("str_offsets", eSectionTypeDWARFDebugStrOffsets)
+        .Case("str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo)
+        .Case("types", eSectionTypeDWARFDebugTypes)
+        .Case("types.dwo", eSectionTypeDWARFDebugTypesDwo)
+        .Default(eSectionTypeOther);
+  }
   return llvm::StringSwitch<SectionType>(Name)
       .Case(".ARM.exidx", eSectionTypeARMexidx)
       .Case(".ARM.extab", eSectionTypeARMextab)
       .Cases(".bss", ".tbss", eSectionTypeZeroFill)
       .Cases(".data", ".tdata", eSectionTypeData)
-      .Case(".debug_abbrev", eSectionTypeDWARFDebugAbbrev)
-      .Case(".debug_abbrev.dwo", eSectionTypeDWARFDebugAbbrevDwo)
-      .Case(".debug_addr", eSectionTypeDWARFDebugAddr)
-      .Case(".debug_aranges", eSectionTypeDWARFDebugAranges)
-      .Case(".debug_cu_index", eSectionTypeDWARFDebugCuIndex)
-      .Case(".debug_frame", eSectionTypeDWARFDebugFrame)
-      .Case(".debug_info", eSectionTypeDWARFDebugInfo)
-      .Case(".debug_info.dwo", eSectionTypeDWARFDebugInfoDwo)
-      .Cases(".debug_line", ".debug_line.dwo", eSectionTypeDWARFDebugLine)
-      .Cases(".debug_line_str", ".debug_line_str.dwo",
-             eSectionTypeDWARFDebugLineStr)
-      .Cases(".debug_loc", ".debug_loc.dwo", eSectionTypeDWARFDebugLoc)
-      .Cases(".debug_loclists", ".debug_loclists.dwo",
-             eSectionTypeDWARFDebugLocLists)
-      .Case(".debug_macinfo", eSectionTypeDWARFDebugMacInfo)
-      .Cases(".debug_macro", ".debug_macro.dwo", eSectionTypeDWARFDebugMacro)
-      .Case(".debug_names", eSectionTypeDWARFDebugNames)
-      .Case(".debug_pubnames", eSectionTypeDWARFDebugPubNames)
-      .Case(".debug_pubtypes", eSectionTypeDWARFDebugPubTypes)
-      .Case(".debug_ranges", eSectionTypeDWARFDebugRanges)
-      .Case(".debug_rnglists", eSectionTypeDWARFDebugRngLists)
-      .Case(".debug_str", eSectionTypeDWARFDebugStr)
-      .Case(".debug_str.dwo", eSectionTypeDWARFDebugStrDwo)
-      .Case(".debug_str_offsets", eSectionTypeDWARFDebugStrOffsets)
-      .Case(".debug_str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo)
-      .Case(".debug_types", eSectionTypeDWARFDebugTypes)
-      .Case(".debug_types.dwo", eSectionTypeDWARFDebugTypesDwo)
       .Case(".eh_frame", eSectionTypeEHFrame)
       .Case(".gnu_debugaltlink", eSectionTypeDWARFGNUDebugAltLink)
       .Case(".gosymtab", eSectionTypeGoSymtab)
@@ -3302,7 +3304,8 @@ size_t ObjectFileELF::ReadSectionData(Se
     return section->GetObjectFile()->ReadSectionData(section, section_data);
 
   size_t result = ObjectFile::ReadSectionData(section, section_data);
-  if (result == 0 || !section->Test(SHF_COMPRESSED))
+  if (result == 0 || !llvm::object::Decompressor::isCompressedELFSection(
+                         section->Get(), section->GetName().GetStringRef()))
     return result;
 
   auto Decompressor = llvm::object::Decompressor::create(




More information about the lldb-commits mailing list