From e17e6c01c8d64b1081661ff7fbf0355bab75754c Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 2 May 2011 15:49:52 +0000 Subject: Only produce the eh_frame section if we have at least one personality function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130692 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/CodeGen/AsmPrinter/DwarfCFIException.cpp') diff --git a/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp index 49680ad308..dbd52c4981 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp @@ -54,25 +54,27 @@ void DwarfCFIException::EndModule() { const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); - if (!TLOF.isFunctionEHFrameSymbolPrivate()) { - // This is a temporary hack to keep sections in the same order they - // were before. This lets us produce bit identical outputs while - // transitioning to CFI. - Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection()); - } - unsigned PerEncoding = TLOF.getPersonalityEncoding(); if ((PerEncoding & 0x70) != dwarf::DW_EH_PE_pcrel) return; // Emit references to all used personality functions + bool AtLeastOne = false; const std::vector &Personalities = MMI->getPersonalities(); for (size_t i = 0, e = Personalities.size(); i != e; ++i) { if (!Personalities[i]) continue; MCSymbol *Sym = Asm->Mang->getSymbol(Personalities[i]); TLOF.emitPersonalityValue(Asm->OutStreamer, Asm->TM, Sym); + AtLeastOne = true; + } + + if (AtLeastOne && !TLOF.isFunctionEHFrameSymbolPrivate()) { + // This is a temporary hack to keep sections in the same order they + // were before. This lets us produce bit identical outputs while + // transitioning to CFI. + Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection()); } } -- cgit v1.2.3