diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 9932306..948caa8 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -116,7 +116,7 @@ namespace llvm { return FrameInfos[i]; } - ArrayRef getFrameInfos() { + MutableArrayRef getFrameInfos() { return FrameInfos; } diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp index e16f7ae..edf1d6d 100644 --- a/lib/MC/MCDwarf.cpp +++ b/lib/MC/MCDwarf.cpp @@ -859,7 +859,6 @@ namespace { const MCSymbol &EmitCIE(MCStreamer &streamer, const MCSymbol *personality, unsigned personalityEncoding, - const MCSymbol *lsda, bool IsSignalFrame, unsigned lsdaEncoding); MCSymbol *EmitFDE(MCStreamer &streamer, @@ -1131,7 +1130,6 @@ bool FrameEmitterImpl::EmitCompactUnwind(MCStreamer &Streamer, const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer, const MCSymbol *personality, unsigned personalityEncoding, - const MCSymbol *lsda, bool IsSignalFrame, unsigned lsdaEncoding) { MCContext &context = streamer.getContext(); @@ -1172,7 +1170,7 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer, Augmentation += "z"; if (personality) Augmentation += "P"; - if (lsda) + if (lsdaEncoding) Augmentation += "L"; Augmentation += "R"; if (IsSignalFrame) @@ -1203,7 +1201,7 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer, // Personality augmentationLength += getSizeForEncoding(streamer, personalityEncoding); } - if (lsda) + if (lsdaEncoding) augmentationLength += 1; // Encoding of the FDE pointers augmentationLength += 1; @@ -1221,7 +1219,7 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer, EmitPersonality(streamer, *personality, personalityEncoding); } - if (lsda) + if (lsdaEncoding) EmitEncodingByte(streamer, lsdaEncoding, "LSDA Encoding"); // Encoding of the FDE pointers @@ -1322,6 +1320,8 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCStreamer &streamer, if (frame.Lsda) EmitSymbol(streamer, *frame.Lsda, frame.LsdaEncoding, "Language Specific Data Area"); + else if (frame.LsdaEncoding) + streamer.EmitIntValue(0, 4); } // Call Frame Instructions @@ -1385,7 +1385,7 @@ void MCDwarfFrameEmitter::Emit(MCStreamer &Streamer, MCObjectFileInfo *MOFI = const_cast(Context.getObjectFileInfo()); FrameEmitterImpl Emitter(UsingCFI, IsEH); - ArrayRef FrameArray = Streamer.getFrameInfos(); + MutableArrayRef FrameArray = Streamer.getFrameInfos(); // Emit the compact unwind info if available. if (IsEH && MOFI->getCompactUnwindSection()) @@ -1405,7 +1405,31 @@ void MCDwarfFrameEmitter::Emit(MCStreamer &Streamer, MCSymbol *FDEEnd = NULL; DenseMap CIEStarts; - const MCSymbol *DummyDebugKey = NULL; + + const MCSymbol *HackPersonality = NULL; + unsigned HackLsdaEncoding = 0; + unsigned HackPersonalityEncoding = 0; + for (unsigned i = 0, n = FrameArray.size(); i < n; ++i) { + const MCDwarfFrameInfo &Frame = FrameArray[i]; + if (!HackPersonality) + HackPersonality = Frame.Personality; + if (!HackLsdaEncoding) + HackLsdaEncoding = Frame.LsdaEncoding; + if (!HackPersonalityEncoding) + HackPersonalityEncoding = Frame.PersonalityEncoding; + } + + for (unsigned i = 0, n = FrameArray.size(); i < n; ++i) { + MCDwarfFrameInfo &Frame = FrameArray[i]; + assert(Frame.Personality == NULL || Frame.Personality == HackPersonality); + Frame.Personality = HackPersonality; + assert(Frame.LsdaEncoding == 0 || Frame.LsdaEncoding == HackLsdaEncoding); + Frame.LsdaEncoding = HackLsdaEncoding; + assert(Frame.PersonalityEncoding == 0 || Frame.PersonalityEncoding == HackPersonalityEncoding); + Frame.PersonalityEncoding = HackPersonalityEncoding; + } + + const MCSymbol *DummyDebugKey = NULL; for (unsigned i = 0, n = FrameArray.size(); i < n; ++i) { const MCDwarfFrameInfo &Frame = FrameArray[i]; CIEKey Key(Frame.Personality, Frame.PersonalityEncoding, @@ -1413,7 +1437,7 @@ void MCDwarfFrameEmitter::Emit(MCStreamer &Streamer, const MCSymbol *&CIEStart = IsEH ? CIEStarts[Key] : DummyDebugKey; if (!CIEStart) CIEStart = &Emitter.EmitCIE(Streamer, Frame.Personality, - Frame.PersonalityEncoding, Frame.Lsda, + Frame.PersonalityEncoding, Frame.IsSignalFrame, Frame.LsdaEncoding);