diff options
author | Alon Zakai <azakai@google.com> | 2020-05-18 15:40:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-18 15:40:10 -0700 |
commit | 417ccb54ccbb0776148f51cb2869c122826db6d9 (patch) | |
tree | bae4291fdc3ff6eee4d721276869352e73bf5c25 /src/wasm/wasm-debug.cpp | |
parent | 86697b641baf3d54dd4c3e0331d5ccec47a33efc (diff) | |
download | binaryen-417ccb54ccbb0776148f51cb2869c122826db6d9.tar.gz binaryen-417ccb54ccbb0776148f51cb2869c122826db6d9.tar.bz2 binaryen-417ccb54ccbb0776148f51cb2869c122826db6d9.zip |
[dwarf] Handle a bad mapped base in debug_loc updating (#2859)
Turns out we had a testcase for this already, but were doing the
wrong thing on it.
Diffstat (limited to 'src/wasm/wasm-debug.cpp')
-rw-r--r-- | src/wasm/wasm-debug.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/wasm/wasm-debug.cpp b/src/wasm/wasm-debug.cpp index 286b63e69..93eb259e9 100644 --- a/src/wasm/wasm-debug.cpp +++ b/src/wasm/wasm-debug.cpp @@ -897,9 +897,23 @@ static void updateLoc(llvm::DWARFYAML::Data& yaml, // This part of the loc no longer has a mapping, so we must ignore it. newStart = newEnd = IGNOREABLE_LOCATION; } else { - // Finally, relativize it against the base. - newStart -= base; - newEnd -= base; + // See if we can relativize it against the base. If things moved around + // so that the base is no longer before the start or the end, then we + // must skip this. That is, if we had something like + // + // [base] [start] [end] + // + // (where the X axis is the offset) and transforms led to + // + // [start] [base] [end] + // + // or such, then give up TODO: perhaps remap with a new base? + if (newStart >= base && newEnd >= base) { + newStart -= base; + newEnd -= base; + } else { + newStart = newEnd = IGNOREABLE_LOCATION; + } } // The loc start and end markers have been preserved. However, TODO // instructions in the middle may have moved around, making the loc no |