Skip to content

Commit b85b64b

Browse files
authored
Fix off-by-one error in DWARF reg-reg location (#317)
The DWARF specification states that the form of an exprloc consists of an unsigned LEB128 length value, followed by the encoded location bytes of the specified length. For some reason we were adding one to the length value being emitted. This looks incorrect to me. The above calculation for REG-REG (a variable stored in two registers) correctly calculates the length of each register type tag, plus the size of the interpolating PIECE tags, plus the size of notation for each register. The extra byte looks wrong. I've tested this locally and it appears to resolve dotnet/runtime#77407. Unfortunately, it also causes llvm-dwarfdump --verify to constantly complain about missing base addresses. I can't confirm at the moment, but my suspicion is that this is revealing an existing bug. Even if this is somehow causing a new bug, I think the resulting symbols with this change are better than the alternative (no working symbols at all).
1 parent b117dbc commit b85b64b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/tools/objwriter/debugInfo/dwarf/dwarfGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ static void EmitVarLocation(MCObjectStreamer *Streamer,
419419
if (IsLocList) {
420420
Streamer->emitIntValue(Len, 2);
421421
} else {
422-
Streamer->emitULEB128IntValue(Len + 1);
422+
Streamer->emitULEB128IntValue(Len);
423423
}
424424

425425
EmitReg(Streamer, DwarfRegNum2);

0 commit comments

Comments
 (0)