diff options
author | Alon Zakai <azakai@google.com> | 2020-09-22 08:44:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-22 08:44:31 -0700 |
commit | b410773b502abfcd8cc225fe4cd36d84108c0aeb (patch) | |
tree | f7758cd6a16ea3821d40f4bd3dedfed2469c725a /third_party/llvm-project/DWARFVisitor.cpp | |
parent | 4b3c35b34c62dc619b1c706e5562e90c089f2419 (diff) | |
download | binaryen-b410773b502abfcd8cc225fe4cd36d84108c0aeb.tar.gz binaryen-b410773b502abfcd8cc225fe4cd36d84108c0aeb.tar.bz2 binaryen-b410773b502abfcd8cc225fe4cd36d84108c0aeb.zip |
DWARF: Fix abbreviation lookups, they are relative to 1 (#3158)
Apparently I misunderstood the DWARF spec on this. Abbreviation offsets are all
relative to 1 (as 0 is not a valid number). For some reason I thought the first DIE's
index was the "base", as in practice LLVM always emits the lowest index there,
and that's what the LLVM YAML code suggested to me.
Diffstat (limited to 'third_party/llvm-project/DWARFVisitor.cpp')
-rw-r--r-- | third_party/llvm-project/DWARFVisitor.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/third_party/llvm-project/DWARFVisitor.cpp b/third_party/llvm-project/DWARFVisitor.cpp index 4b6ed5ada..22df78639 100644 --- a/third_party/llvm-project/DWARFVisitor.cpp +++ b/third_party/llvm-project/DWARFVisitor.cpp @@ -101,19 +101,19 @@ template <typename T> void DWARFYAML::VisitorImpl<T>::traverseDebugInfo() { if (Unit.Entries.empty()) { // XXX BINARYEN continue; } - auto FirstAbbrevCode = Unit.Entries[0].AbbrCode; for (auto &Entry : Unit.Entries) { onStartDIE(Unit, Entry); if (Entry.AbbrCode == 0u) continue; - // XXX BINARYEN - if (Entry.AbbrCode - FirstAbbrevCode + AbbrevStart >= AbbrevEnd) { + // XXX BINARYEN valid abbreviation codes start from 1, so subtract that, + // and are relative to the start of the abbrev table + auto RelativeAbbrIndex = Entry.AbbrCode - 1 + AbbrevStart; + if (RelativeAbbrIndex >= AbbrevEnd) { errs() << "warning: invalid abbreviation code " << Entry.AbbrCode - << " (range: " << FirstAbbrevCode << " : " << AbbrevStart - << ".." << AbbrevEnd << ")\n"; + << " (range: " << AbbrevStart << ".." << AbbrevEnd << ")\n"; continue; } - auto &Abbrev = DebugInfo.AbbrevDecls[Entry.AbbrCode - FirstAbbrevCode + AbbrevStart]; + auto &Abbrev = DebugInfo.AbbrevDecls[RelativeAbbrIndex]; auto FormVal = Entry.Values.begin(); auto AbbrForm = Abbrev.Attributes.begin(); for (; |