Skip to content

Commit cd0cc95

Browse files
authored
DWARF: Ignore debug_loc spans that are invalid (#2939)
An (x, y) span is updated to some (q, r) in the new binary. If q > r then the span is no longer valid - the optimizer has reordered things too much. It's possible this could be flipped, but I'm not certain. It seems safer to just omit these, which are very rare (I only see this on some larger testcases in the emscripten test suite).
1 parent de9f46e commit cd0cc95

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/wasm/wasm-debug.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,8 +992,9 @@ static void updateLoc(llvm::DWARFYAML::Data& yaml,
992992
// a new address for it.
993993
newStart = locationUpdater.getNewStart(loc.Start + oldBase);
994994
newEnd = locationUpdater.getNewEnd(loc.End + oldBase);
995-
if (newStart == 0 || newEnd == 0) {
996-
// This part of the loc no longer has a mapping, so we must ignore it.
995+
if (newStart == 0 || newEnd == 0 || newStart > newEnd) {
996+
// This part of the loc no longer has a mapping, or after the mapping
997+
// it is no longer a proper span, so we must ignore it.
997998
newStart = newEnd = IGNOREABLE_LOCATION;
998999
} else {
9991000
// We picked a new base that ensures it is smaller than the values we

0 commit comments

Comments
 (0)