From f6b37f425fb707b5c97a3f7d3436ab8afb248294 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Thu, 9 Aug 2018 11:52:10 +0300 Subject: [PATCH] [CoreRT armel]Fix for unwinding support for ARM is not fully implemented dotnet/coreclr#5874 Commit migrated from https://github.com/dotnet/coreclr/commit/f4eaea5265b90bdf782bbd62d1cbc246f62a7a75 --- src/coreclr/src/jit/compiler.h | 4 ++++ src/coreclr/src/jit/unwind.cpp | 9 ++++++++- src/coreclr/src/jit/unwindarm.cpp | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/coreclr/src/jit/compiler.h b/src/coreclr/src/jit/compiler.h index 705b293..09ff104 100644 --- a/src/coreclr/src/jit/compiler.h +++ b/src/coreclr/src/jit/compiler.h @@ -7165,6 +7165,10 @@ private: DWORD cfiCodeBytes, const CFI_CODE* const pCfiCode); #endif +#if defined(_TARGET_ARM_) + bool unwindCfiEpilogFormed; // Avoid duplicated unwind info for methods with multiple epilogs (we expect and require + // all the epilogs to be precisely the same) +#endif #endif // _TARGET_UNIX_ diff --git a/src/coreclr/src/jit/unwind.cpp b/src/coreclr/src/jit/unwind.cpp index db120c5..98f8673 100644 --- a/src/coreclr/src/jit/unwind.cpp +++ b/src/coreclr/src/jit/unwind.cpp @@ -122,6 +122,10 @@ void Compiler::unwindGetFuncLocations(FuncInfoDsc* func, void Compiler::createCfiCode(FuncInfoDsc* func, UCHAR codeOffset, UCHAR cfiOpcode, USHORT dwarfReg, INT offset) { +#if defined(_TARGET_ARM_) + if (compGeneratingEpilog && unwindCfiEpilogFormed) + return; +#endif CFI_CODE cfiEntry(codeOffset, cfiOpcode, dwarfReg, offset); func->cfiCodes->push_back(cfiEntry); } @@ -153,7 +157,10 @@ void Compiler::unwindPushPopCFI(regNumber reg) // since it is pushed as a frame register. || (reg == REG_FPBASE) #endif // ETW_EBP_FRAMED -#endif +#endif // UNIX_AMD64_ABI +#if defined(_TARGET_ARM_) + || (reg == REG_R11) || (reg == REG_LR) || (reg == REG_PC) +#endif // _TARGET_ARM_ ) { createCfiCode(func, cbProlog, CFI_REL_OFFSET, mapRegNumToDwarfReg(reg)); diff --git a/src/coreclr/src/jit/unwindarm.cpp b/src/coreclr/src/jit/unwindarm.cpp index 9bb07ec..691d4e1 100644 --- a/src/coreclr/src/jit/unwindarm.cpp +++ b/src/coreclr/src/jit/unwindarm.cpp @@ -194,6 +194,9 @@ void Compiler::unwindBegProlog() if (generateCFIUnwindCodes()) { unwindBegPrologCFI(); +#if defined(_TARGET_ARM_) + unwindCfiEpilogFormed = false; +#endif return; } #endif // _TARGET_UNIX_ @@ -235,6 +238,11 @@ void Compiler::unwindBegEpilog() void Compiler::unwindEndEpilog() { assert(compGeneratingEpilog); +#if defined(_TARGET_UNIX_) +#if defined(_TARGET_ARM_) + unwindCfiEpilogFormed = true; +#endif +#endif // _TARGET_UNIX_ } #if defined(_TARGET_ARM_) -- 2.7.4