[llvm] r269851 - llvm-dwp: Add error handling for multiple type sections in a dwp file.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue May 17 15:00:57 PDT 2016


Author: dblaikie
Date: Tue May 17 17:00:57 2016
New Revision: 269851

URL: http://llvm.org/viewvc/llvm-project?rev=269851&view=rev
Log:
llvm-dwp: Add error handling for multiple type sections in a dwp file.

Added:
    llvm/trunk/test/tools/llvm-dwp/Inputs/multiple_type_sections.dwp
    llvm/trunk/test/tools/llvm-dwp/X86/multiple_type_sections.test
Modified:
    llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp

Added: llvm/trunk/test/tools/llvm-dwp/Inputs/multiple_type_sections.dwp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwp/Inputs/multiple_type_sections.dwp?rev=269851&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/llvm-dwp/Inputs/multiple_type_sections.dwp (added) and llvm/trunk/test/tools/llvm-dwp/Inputs/multiple_type_sections.dwp Tue May 17 17:00:57 2016 differ

Added: llvm/trunk/test/tools/llvm-dwp/X86/multiple_type_sections.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwp/X86/multiple_type_sections.test?rev=269851&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-dwp/X86/multiple_type_sections.test (added)
+++ llvm/trunk/test/tools/llvm-dwp/X86/multiple_type_sections.test Tue May 17 17:00:57 2016
@@ -0,0 +1,3 @@
+RUN: not llvm-dwp %p/../Inputs/multiple_type_sections.dwp -o %t 2>&1 | FileCheck %s
+
+CHECK: error: multiple type unit sections in .dwp file

Modified: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp?rev=269851&r1=269850&r2=269851&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp (original)
+++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp Tue May 17 17:00:57 2016
@@ -537,7 +537,9 @@ static Error write(MCStreamer &Out, Arra
       }
 
       if (!CurTypesSection.empty()) {
-        assert(CurTypesSection.size() == 1);
+        if (CurTypesSection.size() != 1)
+          return make_error<DWPError>(
+              "multiple type unit sections in .dwp file");
         DWARFUnitIndex TUIndex(DW_SECT_TYPES);
         DataExtractor TUIndexData(CurTUIndexSection,
                                   ErrOrObj->getBinary()->isLittleEndian(), 0);




More information about the llvm-commits mailing list