aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCDwarf.cpp
diff options
context:
space:
mode:
authorIgor Kudrin <ikudrin@accesssoftek.com>2020-06-03 16:52:02 +0700
committerIgor Kudrin <ikudrin@accesssoftek.com>2020-06-16 15:50:14 +0700
commitffc5d98d2c0df5f72ce67e5dcb724b64f03f639b (patch)
tree089972226ababe5abefd91758ea9c3fe7c5dd5f7 /llvm/lib/MC/MCDwarf.cpp
parent1e081342d4bb8963080b5a401d1740c0dc203639 (diff)
downloadllvm-ffc5d98d2c0df5f72ce67e5dcb724b64f03f639b.zip
llvm-ffc5d98d2c0df5f72ce67e5dcb724b64f03f639b.tar.gz
llvm-ffc5d98d2c0df5f72ce67e5dcb724b64f03f639b.tar.bz2
[MC] Generate .debug_frame in the 64-bit DWARF format [7/7]
Note that .eh_frame sections are generated in the 32-bit format even when debug sections are 64-bit, for compatibility reasons. They use relative references between entries, so they hardly benefit from the 64-bit format. Differential Revision: https://reviews.llvm.org/D81149
Diffstat (limited to 'llvm/lib/MC/MCDwarf.cpp')
-rw-r--r--llvm/lib/MC/MCDwarf.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 3bb1f42..b1b7b74 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -1614,14 +1614,24 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(const MCDwarfFrameInfo &Frame) {
MCSymbol *sectionEnd = context.createTempSymbol();
+ dwarf::DwarfFormat Format = IsEH ? dwarf::DWARF32 : context.getDwarfFormat();
+ unsigned UnitLengthBytes = dwarf::getUnitLengthFieldByteSize(Format);
+ unsigned OffsetSize = dwarf::getDwarfOffsetByteSize(Format);
+ bool IsDwarf64 = Format == dwarf::DWARF64;
+
+ if (IsDwarf64)
+ // DWARF64 mark
+ Streamer.emitInt32(dwarf::DW_LENGTH_DWARF64);
+
// Length
- const MCExpr *Length =
- MakeStartMinusEndExpr(context, *sectionStart, *sectionEnd, 4);
- emitAbsValue(Streamer, Length, 4);
+ const MCExpr *Length = MakeStartMinusEndExpr(context, *sectionStart,
+ *sectionEnd, UnitLengthBytes);
+ emitAbsValue(Streamer, Length, OffsetSize);
// CIE ID
- unsigned CIE_ID = IsEH ? 0 : -1;
- Streamer.emitInt32(CIE_ID);
+ uint64_t CIE_ID =
+ IsEH ? 0 : (IsDwarf64 ? dwarf::DW64_CIE_ID : dwarf::DW_CIE_ID);
+ Streamer.emitIntValue(CIE_ID, OffsetSize);
// Version
uint8_t CIEVersion = getCIEVersion(IsEH, context.getDwarfVersion());
@@ -1731,9 +1741,16 @@ void FrameEmitterImpl::EmitFDE(const MCSymbol &cieStart,
CFAOffset = InitialCFAOffset;
+ dwarf::DwarfFormat Format = IsEH ? dwarf::DWARF32 : context.getDwarfFormat();
+ unsigned OffsetSize = dwarf::getDwarfOffsetByteSize(Format);
+
+ if (Format == dwarf::DWARF64)
+ // DWARF64 mark
+ Streamer.emitInt32(dwarf::DW_LENGTH_DWARF64);
+
// Length
const MCExpr *Length = MakeStartMinusEndExpr(context, *fdeStart, *fdeEnd, 0);
- emitAbsValue(Streamer, Length, 4);
+ emitAbsValue(Streamer, Length, OffsetSize);
Streamer.emitLabel(fdeStart);
@@ -1742,13 +1759,13 @@ void FrameEmitterImpl::EmitFDE(const MCSymbol &cieStart,
if (IsEH) {
const MCExpr *offset =
MakeStartMinusEndExpr(context, cieStart, *fdeStart, 0);
- emitAbsValue(Streamer, offset, 4);
+ emitAbsValue(Streamer, offset, OffsetSize);
} else if (!asmInfo->doesDwarfUseRelocationsAcrossSections()) {
const MCExpr *offset =
MakeStartMinusEndExpr(context, SectionStart, cieStart, 0);
- emitAbsValue(Streamer, offset, 4);
+ emitAbsValue(Streamer, offset, OffsetSize);
} else {
- Streamer.emitSymbolValue(&cieStart, 4,
+ Streamer.emitSymbolValue(&cieStart, OffsetSize,
asmInfo->needsDwarfSectionOffsetDirective());
}