Created
October 12, 2020 04:22
-
-
Save benesch/7052d40ed9de9a3a5d3886a060ec3a3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: arch/x86_64/sys/__sigtramp2.S | |
=================================================================== | |
RCS file: /cvsroot/src/lib/libc/arch/x86_64/sys/__sigtramp2.S,v | |
retrieving revision 1.7 | |
diff -u -r1.7 __sigtramp2.S | |
--- arch/x86_64/sys/__sigtramp2.S 2 Dec 2019 01:38:54 -0000 1.7 | |
+++ arch/x86_64/sys/__sigtramp2.S 12 Oct 2020 04:22:11 -0000 | |
@@ -36,14 +36,40 @@ | |
*/ | |
#include "SYS.h" | |
+#include "assym.h" | |
/* | |
* The x86-64 signal trampoline is invoked only to return from | |
* the signal; the kernel calls the signal handler directly. | |
+ * | |
+ * The unwind entry includes the one byte prior to the trampoline | |
+ * because the unwinder will look up (return PC - 1) while unwinding. | |
+ * Normally (return PC - 1) computes an address inside the call | |
+ * instruction that created the child frame, but here there is no call | |
+ * instruction so we have to manually add padding. | |
*/ | |
+ .cfi_startproc simple | |
+ .cfi_signal_frame | |
+ .cfi_def_cfa r15, 0 | |
+ .cfi_offset rax, _OFFSETOF_UC_GREGS_RAX | |
+ .cfi_offset rdx, _OFFSETOF_UC_GREGS_RDX | |
+ .cfi_offset rcx, _OFFSETOF_UC_GREGS_RCX | |
+ .cfi_offset rbx, _OFFSETOF_UC_GREGS_RBX | |
+ .cfi_offset rsi, _OFFSETOF_UC_GREGS_RSI | |
+ .cfi_offset rdi, _OFFSETOF_UC_GREGS_RDI | |
+ .cfi_offset rbp, _OFFSETOF_UC_GREGS_RBP | |
+ /* The unwinder will use the CFA to restore RSP. */ | |
+ .cfi_offset r8, _OFFSETOF_UC_GREGS_R8 | |
+ .cfi_offset r9, _OFFSETOF_UC_GREGS_R9 | |
+ .cfi_offset r10, _OFFSETOF_UC_GREGS_R10 | |
+ .cfi_offset r11, _OFFSETOF_UC_GREGS_R11 | |
+ .cfi_offset r12, _OFFSETOF_UC_GREGS_R12 | |
+ .cfi_offset r13, _OFFSETOF_UC_GREGS_R13 | |
+ .cfi_offset r14, _OFFSETOF_UC_GREGS_R14 | |
+ .cfi_offset r15, _OFFSETOF_UC_GREGS_R15 | |
+ .cfi_offset rip, _OFFSETOF_UC_GREGS_RIP | |
+ nop | |
NENTRY(__sigtramp_siginfo_2) | |
- .cfi_startproc | |
- .cfi_def_cfa rsp, 8 | |
movq %r15,%rdi | |
movq $SYS_setcontext, %rax | |
syscall | |
Index: arch/x86_64/genassym.cf | |
=================================================================== | |
RCS file: arch/x86_64/genassym.cf | |
diff -N arch/x86_64/genassym.cf | |
--- /dev/null 1 Jan 1970 00:00:00 -0000 | |
+++ arch/x86_64/genassym.cf 12 Oct 2020 04:22:11 -0000 | |
@@ -0,0 +1,19 @@ | |
+include <ucontext.h> | |
+ | |
+define _OFFSETOF_UC_GREGS_RAX offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RAX]) | |
+define _OFFSETOF_UC_GREGS_RDX offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RDX]) | |
+define _OFFSETOF_UC_GREGS_RCX offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RCX]) | |
+define _OFFSETOF_UC_GREGS_RBX offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RBX]) | |
+define _OFFSETOF_UC_GREGS_RSI offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RSI]) | |
+define _OFFSETOF_UC_GREGS_RDI offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RDI]) | |
+define _OFFSETOF_UC_GREGS_RBP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RBP]) | |
+define _OFFSETOF_UC_GREGS_RSP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RSP]) | |
+define _OFFSETOF_UC_GREGS_R8 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R8]) | |
+define _OFFSETOF_UC_GREGS_R9 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R9]) | |
+define _OFFSETOF_UC_GREGS_R10 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R10]) | |
+define _OFFSETOF_UC_GREGS_R11 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R11]) | |
+define _OFFSETOF_UC_GREGS_R12 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R12]) | |
+define _OFFSETOF_UC_GREGS_R13 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R13]) | |
+define _OFFSETOF_UC_GREGS_R14 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R14]) | |
+define _OFFSETOF_UC_GREGS_R15 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R15]) | |
+define _OFFSETOF_UC_GREGS_RIP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RIP]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment