summaryrefslogtreecommitdiff
path: root/third_party/llvm-project/DWARFVisitor.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-01-21 17:24:01 -0800
committerGitHub <noreply@github.com>2020-01-21 17:24:01 -0800
commit51fff211d7aae002ff28e1c6245e3f9349493f11 (patch)
tree74268f2442f95d440a9274a2aafb3564bad5cbb5 /third_party/llvm-project/DWARFVisitor.cpp
parent52550c26325ff3d6649fa84c83bf8d4ce9ad4fde (diff)
downloadbinaryen-51fff211d7aae002ff28e1c6245e3f9349493f11.tar.gz
binaryen-51fff211d7aae002ff28e1c6245e3f9349493f11.tar.bz2
binaryen-51fff211d7aae002ff28e1c6245e3f9349493f11.zip
Handle an invalid AbbrCode in DWARF handling (#2607)
Fixes the testcase in #2343 (comment) Looks like that's from Rust. Not sure why it would have an invalid abbreviation code, but perhaps the LLVM there emits dwarf differently than we've tested on so far. May be worth investigating further, but for now emit a warning, skip that element, and don't crash. Also fix valgrind warnings about Span values not being initialized, which was invalid and bad as well (wasted memory in our maps, and might have overlapped with real values), and interfered with figuring this out.
Diffstat (limited to 'third_party/llvm-project/DWARFVisitor.cpp')
-rw-r--r--third_party/llvm-project/DWARFVisitor.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/third_party/llvm-project/DWARFVisitor.cpp b/third_party/llvm-project/DWARFVisitor.cpp
index 35d5ccf57..05c4194e3 100644
--- a/third_party/llvm-project/DWARFVisitor.cpp
+++ b/third_party/llvm-project/DWARFVisitor.cpp
@@ -55,6 +55,13 @@ template <typename T> void DWARFYAML::VisitorImpl<T>::traverseDebugInfo() {
onStartDIE(Unit, Entry);
if (Entry.AbbrCode == 0u)
continue;
+ // XXX BINARYEN
+ if (Entry.AbbrCode - FirstAbbrevCode >= DebugInfo.AbbrevDecls.size()) {
+ errs() << "warning: invalid abbreviation code " << Entry.AbbrCode <<
+ " (range: " << FirstAbbrevCode << "-" <<
+ (DebugInfo.AbbrevDecls.size() - FirstAbbrevCode) << ")\n";
+ continue;
+ }
auto &Abbrev = DebugInfo.AbbrevDecls[Entry.AbbrCode - FirstAbbrevCode];
auto FormVal = Entry.Values.begin();
auto AbbrForm = Abbrev.Attributes.begin();