aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ObjectYAML/DWARFVisitor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/ObjectYAML/DWARFVisitor.cpp')
-rw-r--r--llvm/lib/ObjectYAML/DWARFVisitor.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/llvm/lib/ObjectYAML/DWARFVisitor.cpp b/llvm/lib/ObjectYAML/DWARFVisitor.cpp
index ecb5967ac532..a2dd37b5fe32 100644
--- a/llvm/lib/ObjectYAML/DWARFVisitor.cpp
+++ b/llvm/lib/ObjectYAML/DWARFVisitor.cpp
@@ -9,7 +9,10 @@
//===----------------------------------------------------------------------===//
#include "DWARFVisitor.h"
+#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/ObjectYAML/DWARFYAML.h"
+#include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
using namespace llvm;
@@ -34,7 +37,7 @@ void DWARFYAML::VisitorImpl<T>::onVariableSizeValue(uint64_t U, unsigned Size) {
}
static unsigned getOffsetSize(const DWARFYAML::Unit &Unit) {
- return Unit.Length.isDWARF64() ? 8 : 4;
+ return Unit.Format == dwarf::DWARF64 ? 8 : 4;
}
static unsigned getRefSize(const DWARFYAML::Unit &Unit) {
@@ -43,16 +46,24 @@ static unsigned getRefSize(const DWARFYAML::Unit &Unit) {
return getOffsetSize(Unit);
}
-template <typename T> void DWARFYAML::VisitorImpl<T>::traverseDebugInfo() {
+template <typename T> Error DWARFYAML::VisitorImpl<T>::traverseDebugInfo() {
for (auto &Unit : DebugInfo.CompileUnits) {
onStartCompileUnit(Unit);
- auto FirstAbbrevCode = Unit.Entries[0].AbbrCode;
+ if (Unit.Entries.empty())
+ continue;
for (auto &Entry : Unit.Entries) {
onStartDIE(Unit, Entry);
- if (Entry.AbbrCode == 0u)
+ uint32_t AbbrCode = Entry.AbbrCode;
+ if (AbbrCode == 0 || Entry.Values.empty())
continue;
- auto &Abbrev = DebugInfo.AbbrevDecls[Entry.AbbrCode - FirstAbbrevCode];
+
+ if (AbbrCode > DebugInfo.AbbrevDecls.size())
+ return createStringError(
+ errc::invalid_argument,
+ "abbrev code must be less than or equal to the number of "
+ "entries in abbreviation table");
+ const DWARFYAML::Abbrev &Abbrev = DebugInfo.AbbrevDecls[AbbrCode - 1];
auto FormVal = Entry.Values.begin();
auto AbbrForm = Abbrev.Attributes.begin();
for (;
@@ -105,6 +116,12 @@ template <typename T> void DWARFYAML::VisitorImpl<T>::traverseDebugInfo() {
""));
break;
}
+ case dwarf::DW_FORM_strx:
+ case dwarf::DW_FORM_addrx:
+ case dwarf::DW_FORM_rnglistx:
+ case dwarf::DW_FORM_loclistx:
+ onValue((uint64_t)FormVal->Value, /*LEB=*/true);
+ break;
case dwarf::DW_FORM_data1:
case dwarf::DW_FORM_ref1:
case dwarf::DW_FORM_flag:
@@ -170,6 +187,8 @@ template <typename T> void DWARFYAML::VisitorImpl<T>::traverseDebugInfo() {
}
onEndCompileUnit(Unit);
}
+
+ return Error::success();
}
// Explicitly instantiate the two template expansions.