[PATCH] D77143: [llvm-dwp] Refuse DWARFv5 input DWP files.

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 07:44:45 PDT 2020


ikudrin created this revision.
ikudrin added reviewers: dblaikie, jhen, probinson, aprantl.
ikudrin added projects: LLVM, debug-info.
Herald added a subscriber: arphaman.
ikudrin added a parent revision: D75929: [DebugInfo] Support DWARFv5 index sections..

The library can parse DWARFv5 unit index sections of DWP files, but `llvm-dwp` is not ready to process them. Refuse such input files for now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77143

Files:
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/test/tools/llvm-dwp/X86/unsupported_cu_index_version.s
  llvm/tools/llvm-dwp/llvm-dwp.cpp


Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===================================================================
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -612,6 +612,8 @@
     DataExtractor CUIndexData(CurCUIndexSection, Obj.isLittleEndian(), 0);
     if (!CUIndex.parse(CUIndexData))
       return make_error<DWPError>("failed to parse cu_index");
+    if (CUIndex.getVersion() != 2)
+      return make_error<DWPError>("unsupported cu_index version");
 
     for (const DWARFUnitIndex::Entry &E : CUIndex.getRows()) {
       auto *I = E.getOffsets();
@@ -647,6 +649,8 @@
       DataExtractor TUIndexData(CurTUIndexSection, Obj.isLittleEndian(), 0);
       if (!TUIndex.parse(TUIndexData))
         return make_error<DWPError>("failed to parse tu_index");
+      if (TUIndex.getVersion() != 2)
+        return make_error<DWPError>("unsupported tu_index version");
       addAllTypesFromDWP(
           Out, TypeIndexEntries, TUIndex, TypesSection, CurTypesSection.front(),
           CurEntry,
Index: llvm/test/tools/llvm-dwp/X86/unsupported_cu_index_version.s
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-dwp/X86/unsupported_cu_index_version.s
@@ -0,0 +1,50 @@
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.dwp
+# RUN: not llvm-dwp %t.dwp -o %t 2>&1 | FileCheck %s
+
+# CHECK: error: unsupported cu_index version
+
+.section .debug_abbrev.dwo, "e", @progbits
+.LAbbrevBegin:
+    .uleb128 1                      # Abbreviation Code
+    .uleb128 17                     # DW_TAG_compile_unit
+    .byte 1                         # DW_CHILDREN_no
+    .byte 0                         # EOM(1)
+    .byte 0                         # EOM(2)
+    .byte 0                         # EOM(3)
+.LAbbrevEnd:
+
+    .section .debug_info.dwo, "e", @progbits
+.LCUBegin:
+    .long .LCUEnd-.LCUVersion       # Length of Unit
+.LCUVersion:
+    .short 5                        # Version
+    .byte 5                         # DW_UT_split_compile
+    .byte 8                         # Address size
+    .long 0                         # Abbrev offset
+    .quad 0x1100001122222222        # DWO id
+    .uleb128 1                      # Abbrev [1] DW_TAG_compile_unit
+.LCUEnd:
+
+    .section .debug_cu_index, "", @progbits
+## Header:
+    .short 5                        # Version
+    .space 2                        # Padding
+    .long 2                         # Section count
+    .long 1                         # Unit count
+    .long 2                         # Slot count
+## Hash Table of Signatures:
+    .quad 0x1100001122222222
+    .quad 0
+## Parallel Table of Indexes:
+    .long 1
+    .long 0
+## Table of Section Offsets:
+## Row 0:
+    .long 1                         # DW_SECT_INFO
+    .long 3                         # DW_SECT_ABBREV
+## Row 1:
+    .long 0                         # Offset in .debug_info.dwo
+    .long 0                         # Offset in .debug_abbrev.dwo
+## Table of Section Sizes:
+    .long .LCUEnd-.LCUBegin         # Size in .debug_info.dwo
+    .long .LAbbrevEnd-.LAbbrevBegin # Size in .debug_abbrev.dwo
Index: llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
===================================================================
--- llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
@@ -139,6 +139,8 @@
   bool parse(DataExtractor IndexData);
   void dump(raw_ostream &OS) const;
 
+  uint32_t getVersion() const { return Header.Version; }
+
   const Entry *getFromOffset(uint32_t Offset) const;
   const Entry *getFromHash(uint64_t Offset) const;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77143.253880.patch
Type: text/x-patch
Size: 3663 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200331/70ca785c/attachment-0001.bin>


More information about the llvm-commits mailing list