diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp --- a/llvm/lib/MC/MCDwarf.cpp +++ b/llvm/lib/MC/MCDwarf.cpp @@ -476,21 +476,11 @@ // Create a symbol for the end of the section (to be set when we get there). MCSymbol *LineEndSym = context.createTempSymbol(); - - unsigned UnitLengthBytes = - dwarf::getUnitLengthFieldByteSize(context.getDwarfFormat()); unsigned OffsetSize = dwarf::getDwarfOffsetByteSize(context.getDwarfFormat()); - if (context.getDwarfFormat() == dwarf::DWARF64) - // Emit DWARF64 mark. - MCOS->emitInt32(dwarf::DW_LENGTH_DWARF64); - - // The length field does not include itself and, in case of the 64-bit DWARF - // format, the DWARF64 mark. - emitAbsValue(*MCOS, - makeEndMinusStartExpr(context, *LineStartSym, *LineEndSym, - UnitLengthBytes), - OffsetSize); + MCOS->emitDwarfUnitLength(LineEndSym, "unit length"); + MCSymbol *SymWithoutUnitLength = context.createTempSymbol("debug_line_"); + MCOS->emitLabel(SymWithoutUnitLength); // Next 2 bytes is the Version. unsigned LineTableVersion = context.getDwarfVersion(); @@ -498,7 +488,7 @@ // Keep track of the bytes between the very start and where the header length // comes out. - unsigned PreHeaderLengthBytes = UnitLengthBytes + 2; + unsigned PreHeaderLengthBytes = 2; // In v5, we get address info next. if (LineTableVersion >= 5) { @@ -513,7 +503,7 @@ // Length of the prologue, is the next 4 bytes (8 bytes for DWARF64). This is // actually the length from after the length word, to the end of the prologue. emitAbsValue(*MCOS, - makeEndMinusStartExpr(context, *LineStartSym, *ProEndSym, + makeEndMinusStartExpr(context, *SymWithoutUnitLength, *ProEndSym, (PreHeaderLengthBytes + OffsetSize)), OffsetSize);