MCOS->EmitULEB128IntValue(1);
MCOS->EmitULEB128IntValue(dwarf::DW_TAG_compile_unit);
MCOS->EmitIntValue(dwarf::DW_CHILDREN_yes, 1);
- EmitAbbrev(MCOS, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4);
- if (MCOS->getContext().getGenDwarfSectionSyms().size() > 1 &&
- MCOS->getContext().getDwarfVersion() >= 3) {
- EmitAbbrev(MCOS, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4);
+ EmitAbbrev(MCOS, dwarf::DW_AT_stmt_list, context.getDwarfVersion() >= 4
+ ? dwarf::DW_FORM_sec_offset
+ : dwarf::DW_FORM_data4);
+ if (context.getGenDwarfSectionSyms().size() > 1 &&
+ context.getDwarfVersion() >= 3) {
+ EmitAbbrev(MCOS, dwarf::DW_AT_ranges, context.getDwarfVersion() >= 4
+ ? dwarf::DW_FORM_sec_offset
+ : dwarf::DW_FORM_data4);
} else {
EmitAbbrev(MCOS, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr);
EmitAbbrev(MCOS, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr);
int CFAOffset = 0;
int InitialCFAOffset = 0;
bool IsEH;
- const MCSymbol *SectionStart = nullptr;
MCObjectStreamer &Streamer;
public:
FrameEmitterImpl(bool IsEH, MCObjectStreamer &Streamer)
: IsEH(IsEH), Streamer(Streamer) {}
- void setSectionStart(const MCSymbol *Label) { SectionStart = Label; }
-
/// Emit the unwind information in a compact way.
void EmitCompactUnwind(const MCDwarfFrameInfo &frame);
bool IsSignalFrame, unsigned lsdaEncoding,
bool IsSimple);
void EmitFDE(const MCSymbol &cieStart, const MCDwarfFrameInfo &frame,
- bool LastInSection);
+ bool LastInSection, const MCSymbol &SectionStart);
void EmitCFIInstructions(ArrayRef<MCCFIInstruction> Instrs,
MCSymbol *BaseLabel);
void EmitCFIInstruction(const MCCFIInstruction &Instr);
case 3:
return 3;
case 4:
+ case 5:
return 4;
}
llvm_unreachable("Unknown version");
void FrameEmitterImpl::EmitFDE(const MCSymbol &cieStart,
const MCDwarfFrameInfo &frame,
- bool LastInSection) {
+ bool LastInSection,
+ const MCSymbol &SectionStart) {
MCContext &context = Streamer.getContext();
MCSymbol *fdeStart = context.createTempSymbol();
MCSymbol *fdeEnd = context.createTempSymbol();
emitAbsValue(Streamer, offset, 4);
} else if (!asmInfo->doesDwarfUseRelocationsAcrossSections()) {
const MCExpr *offset =
- MakeStartMinusEndExpr(Streamer, *SectionStart, cieStart, 0);
+ MakeStartMinusEndExpr(Streamer, SectionStart, cieStart, 0);
emitAbsValue(Streamer, offset, 4);
} else {
Streamer.EmitSymbolValue(&cieStart, 4);
}
namespace {
- struct CIEKey {
- static const CIEKey getEmptyKey() {
- return CIEKey(nullptr, 0, -1, false, false);
- }
- static const CIEKey getTombstoneKey() {
- return CIEKey(nullptr, -1, 0, false, false);
- }
+struct CIEKey {
+ static const CIEKey getEmptyKey() {
+ return CIEKey(nullptr, 0, -1, false, false);
+ }
+ static const CIEKey getTombstoneKey() {
+ return CIEKey(nullptr, -1, 0, false, false);
+ }
- CIEKey(const MCSymbol *Personality_, unsigned PersonalityEncoding_,
- unsigned LsdaEncoding_, bool IsSignalFrame_, bool IsSimple_)
- : Personality(Personality_), PersonalityEncoding(PersonalityEncoding_),
- LsdaEncoding(LsdaEncoding_), IsSignalFrame(IsSignalFrame_),
- IsSimple(IsSimple_) {}
- const MCSymbol *Personality;
- unsigned PersonalityEncoding;
- unsigned LsdaEncoding;
- bool IsSignalFrame;
- bool IsSimple;
- };
+ CIEKey(const MCSymbol *Personality, unsigned PersonalityEncoding,
+ unsigned LsdaEncoding, bool IsSignalFrame, bool IsSimple)
+ : Personality(Personality), PersonalityEncoding(PersonalityEncoding),
+ LsdaEncoding(LsdaEncoding), IsSignalFrame(IsSignalFrame),
+ IsSimple(IsSimple) {}
+ const MCSymbol *Personality;
+ unsigned PersonalityEncoding;
+ unsigned LsdaEncoding;
+ bool IsSignalFrame;
+ bool IsSimple;
+};
} // anonymous namespace
namespace llvm {
- template <>
- struct DenseMapInfo<CIEKey> {
- static CIEKey getEmptyKey() {
- return CIEKey::getEmptyKey();
- }
- static CIEKey getTombstoneKey() {
- return CIEKey::getTombstoneKey();
- }
- static unsigned getHashValue(const CIEKey &Key) {
- return static_cast<unsigned>(hash_combine(Key.Personality,
- Key.PersonalityEncoding,
- Key.LsdaEncoding,
- Key.IsSignalFrame,
- Key.IsSimple));
- }
- static bool isEqual(const CIEKey &LHS,
- const CIEKey &RHS) {
- return LHS.Personality == RHS.Personality &&
- LHS.PersonalityEncoding == RHS.PersonalityEncoding &&
- LHS.LsdaEncoding == RHS.LsdaEncoding &&
- LHS.IsSignalFrame == RHS.IsSignalFrame &&
- LHS.IsSimple == RHS.IsSimple;
- }
- };
+template <> struct DenseMapInfo<CIEKey> {
+ static CIEKey getEmptyKey() { return CIEKey::getEmptyKey(); }
+ static CIEKey getTombstoneKey() { return CIEKey::getTombstoneKey(); }
+ static unsigned getHashValue(const CIEKey &Key) {
+ return static_cast<unsigned>(
+ hash_combine(Key.Personality, Key.PersonalityEncoding, Key.LsdaEncoding,
+ Key.IsSignalFrame, Key.IsSimple));
+ }
+ static bool isEqual(const CIEKey &LHS, const CIEKey &RHS) {
+ return LHS.Personality == RHS.Personality &&
+ LHS.PersonalityEncoding == RHS.PersonalityEncoding &&
+ LHS.LsdaEncoding == RHS.LsdaEncoding &&
+ LHS.IsSignalFrame == RHS.IsSignalFrame &&
+ LHS.IsSimple == RHS.IsSimple;
+ }
+};
} // namespace llvm
void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
Streamer.SwitchSection(&Section);
MCSymbol *SectionStart = Context.createTempSymbol();
Streamer.EmitLabel(SectionStart);
- Emitter.setSectionStart(SectionStart);
DenseMap<CIEKey, const MCSymbol *> CIEStarts;
Frame.Lsda, Frame.IsSignalFrame,
Frame.LsdaEncoding, Frame.IsSimple);
- Emitter.EmitFDE(*CIEStart, Frame, I == E);
+ Emitter.EmitFDE(*CIEStart, Frame, I == E, *SectionStart);
}
}