summaryrefslogtreecommitdiff
path: root/packaging/0007-Fix-unwinding-of-funclet-with-no-epilog-on-x86-Linux.patch
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/0007-Fix-unwinding-of-funclet-with-no-epilog-on-x86-Linux.patch')
-rw-r--r--packaging/0007-Fix-unwinding-of-funclet-with-no-epilog-on-x86-Linux.patch49
1 files changed, 49 insertions, 0 deletions
diff --git a/packaging/0007-Fix-unwinding-of-funclet-with-no-epilog-on-x86-Linux.patch b/packaging/0007-Fix-unwinding-of-funclet-with-no-epilog-on-x86-Linux.patch
new file mode 100644
index 0000000000..8c4a894564
--- /dev/null
+++ b/packaging/0007-Fix-unwinding-of-funclet-with-no-epilog-on-x86-Linux.patch
@@ -0,0 +1,49 @@
+From 965675df0087f4570dc4cfdbab9ddf99623a3186 Mon Sep 17 00:00:00 2001
+From: Igor Kulaychuk <i.kulaychuk@samsung.com>
+Date: Fri, 6 Apr 2018 18:11:37 +0300
+Subject: [PATCH 7/7] Fix unwinding of funclet with no epilog on x86/Linux
+
+---
+ src/vm/eetwain.cpp | 19 +++++--------------
+ 1 file changed, 5 insertions(+), 14 deletions(-)
+
+diff --git a/src/vm/eetwain.cpp b/src/vm/eetwain.cpp
+index fbf669b..a2ceb19 100644
+--- a/src/vm/eetwain.cpp
++++ b/src/vm/eetwain.cpp
+@@ -36,7 +36,8 @@
+ #define X86_INSTR_PUSH_EBP 0x55 // push ebp
+ #define X86_INSTR_W_MOV_EBP_ESP 0xEC8B // mov ebp, esp
+ #define X86_INSTR_POP_ECX 0x59 // pop ecx
+-#define X86_INSTR_RET 0xC2 // ret
++#define X86_INSTR_RET 0xC2 // ret imm16
++#define X86_INSTR_RETN 0xC3 // ret
+ #define X86_INSTR_w_LEA_ESP_EBP_BYTE_OFFSET 0x658d // lea esp, [ebp-bOffset]
+ #define X86_INSTR_w_LEA_ESP_EBP_DWORD_OFFSET 0xa58d // lea esp, [ebp-dwOffset]
+ #define X86_INSTR_JMP_NEAR_REL32 0xE9 // near jmp rel32
+@@ -3839,19 +3840,9 @@ bool UnwindEbpDoubleAlignFrame(
+ // epilog: add esp, 12
+ // ret
+ // SP alignment padding should be added for all instructions except the first one and the last one.
+- TADDR funcletStart = pCodeInfo->GetJitManager()->GetFuncletStartAddress(pCodeInfo);
+-
+- const ULONG32 funcletLastInstSize = 1; // 0xc3, ret
+- BOOL atFuncletLastInst = (pCodeInfo->GetRelOffset() + funcletLastInstSize) >= info->methodSize;
+- if (!atFuncletLastInst)
+- {
+- EECodeInfo nextCodeInfo;
+- nextCodeInfo.Init(pCodeInfo->GetCodeAddress() + funcletLastInstSize);
+- atFuncletLastInst = !nextCodeInfo.IsValid() || !nextCodeInfo.IsFunclet() ||
+- nextCodeInfo.GetJitManager()->GetFuncletStartAddress(&nextCodeInfo) != funcletStart;
+- }
+-
+- if (!atFuncletLastInst && funcletStart != pCodeInfo->GetCodeAddress())
++ // Epilog may not exist (unreachable), so we need to check the instruction code.
++ const TADDR funcletStart = pCodeInfo->GetJitManager()->GetFuncletStartAddress(pCodeInfo);
++ if (funcletStart != pCodeInfo->GetCodeAddress() && methodStart[pCodeInfo->GetRelOffset()] != X86_INSTR_RETN)
+ baseSP += 12;
+
+ pContext->PCTAddr = baseSP;
+--
+2.7.4
+