From 1d4ce2ab962fee691239d58c8157c12b8037f9de Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Tue, 20 Nov 2007 23:24:42 +0000 Subject: Fix .eh table linkage issues on Darwin. Some EH support for Darwin PPC, but it's not fully working yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44258 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/DwarfWriter.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'lib/CodeGen/DwarfWriter.cpp') diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp index 2efb8002f6..d1f195d556 100644 --- a/lib/CodeGen/DwarfWriter.cpp +++ b/lib/CodeGen/DwarfWriter.cpp @@ -2764,12 +2764,15 @@ private: bool hasCalls; bool hasLandingPads; std::vector Moves; + Function::LinkageTypes linkage; FunctionEHFrameInfo(const std::string &FN, unsigned Num, unsigned P, bool hC, bool hL, - const std::vector &M): + const std::vector &M, + Function::LinkageTypes l): FnName(FN), Number(Num), PersonalityIndex(P), - hasCalls(hC), hasLandingPads(hL), Moves(M) { } + hasCalls(hC), hasLandingPads(hL), Moves(M), + linkage(l) { } }; std::vector EHFrames; @@ -2867,15 +2870,25 @@ private: Asm->SwitchToTextSection(TAI->getDwarfEHFrameSection()); // Externally visible entry into the functions eh frame info. - if (const char *GlobalDirective = TAI->getGlobalDirective()) - O << GlobalDirective << EHFrameInfo.FnName << "\n"; - + // If the corresponding function is static, this should not be + // externally visible. + if (EHFrameInfo.linkage != Function::InternalLinkage) { + if (const char *GlobalEHDirective = TAI->getGlobalEHDirective()) + O << GlobalEHDirective << EHFrameInfo.FnName << "\n"; + } + // If there are no calls then you can't unwind. if (!EHFrameInfo.hasCalls) { O << EHFrameInfo.FnName << " = 0\n"; } else { O << EHFrameInfo.FnName << ":\n"; - + + // If corresponding function is weak definition, this should be too. + if ((EHFrameInfo.linkage == Function::WeakLinkage || + EHFrameInfo.linkage == Function::LinkOnceLinkage) && + TAI->getWeakDefDirective()) + O << TAI->getWeakDefDirective() << EHFrameInfo.FnName << "\n"; + // EH frame header. EmitDifference("eh_frame_end", EHFrameInfo.Number, "eh_frame_begin", EHFrameInfo.Number, true); @@ -3362,7 +3375,8 @@ public: MMI->getPersonalityIndex(), MF->getFrameInfo()->hasCalls(), !MMI->getLandingPads().empty(), - MMI->getFrameMoves())); + MMI->getFrameMoves(), + MF->getFunction()->getLinkage())); } }; -- cgit v1.2.3-18-g5258