]> granicus.if.org Git - llvm/commitdiff
[dsymutil] Fix assertion triggered by empty address range.
authorJonas Devlieghere <jonas@devlieghere.com>
Tue, 8 Jan 2019 01:08:09 +0000 (01:08 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Tue, 8 Jan 2019 01:08:09 +0000 (01:08 +0000)
An assertion was hit when running dsymutil on a gcc generated binary
that contained an empty address range. Address ranges are stored in an
interval map of half open intervals. Since the interval is empty and
therefore meaningless, we simply don't add it to the map.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350591 91177308-0d34-0410-b5e6-96231b3b80d8

tools/dsymutil/CompileUnit.cpp

index 67e1739ae1084d6105f0144918fa9624c7cb9d94..4654e41b2176fffa1f0ccbf48a1c35b6f8a711e7 100644 (file)
@@ -92,7 +92,11 @@ void CompileUnit::addLabelLowPc(uint64_t LabelLowPc, int64_t PcOffset) {
 
 void CompileUnit::addFunctionRange(uint64_t FuncLowPc, uint64_t FuncHighPc,
                                    int64_t PcOffset) {
-  Ranges.insert(FuncLowPc, FuncHighPc, PcOffset);
+  //  Don't add empty ranges to the interval map.  They are a problem because
+  //  the interval map expects half open intervals. This is safe because they
+  //  are empty anyway.
+  if (FuncHighPc != FuncLowPc)
+    Ranges.insert(FuncLowPc, FuncHighPc, PcOffset);
   this->LowPc = std::min(LowPc, FuncLowPc + PcOffset);
   this->HighPc = std::max(HighPc, FuncHighPc + PcOffset);
 }