summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWANG Xuerui <xen0n@gentoo.org>2022-08-30 23:35:16 +0800
committerStephen M. Webb <stephen.webb@bregmasoft.ca>2022-11-07 10:32:46 -0500
commita61276ca7d8971ee9f30f9d53ca18624687f5ba9 (patch)
tree62e34e91966b2a0607f6e65f80a5b4edb68ea272
parent6cf38561ae768ac6d72976e0c62f148e5082e447 (diff)
downloadlibunwind-a61276ca7d8971ee9f30f9d53ca18624687f5ba9.tar.gz
[LoongArch64] Reflect the kernel ABI changes since the port went upstream
The original port was done with an early in-house port of Linux that, in addition to slightly different UAPI headers, also featured a MIPS-like ABI (the so-called "old world" ABI). The upstream ABI has been revised since long ago and already frozen, so adjust the port for the "new world". In particular, we don't have the 24-byte signal trampoline area any more which was a MIPS o32 thing. We don't need to keep compatibility for the old-world kernels, because distributions using said kernels invariably packaged their own libunwind fork with corresponding support, and the few users tracking upstream kernels should all have moved on. Fixes: c5f1d12c77de ("Add port for Linux on LoongArch") Signed-off-by: Youling Tang <tangyouling@loongson.cn> Signed-off-by: WANG Xuerui <xen0n@gentoo.org>
-rw-r--r--include/libunwind-loongarch64.h2
-rw-r--r--src/loongarch64/Gresume.c1
-rw-r--r--src/loongarch64/Gstep.c3
-rw-r--r--src/loongarch64/offsets.h12
4 files changed, 7 insertions, 11 deletions
diff --git a/include/libunwind-loongarch64.h b/include/libunwind-loongarch64.h
index 806cf7df..1e9366ed 100644
--- a/include/libunwind-loongarch64.h
+++ b/include/libunwind-loongarch64.h
@@ -88,7 +88,7 @@ typedef enum
UNW_LOONGARCH64_R30,
UNW_LOONGARCH64_R31,
- UNW_LOONGARCH64_PC = 32,
+ UNW_LOONGARCH64_PC = 33,
/* FIXME: Other registers! */
diff --git a/src/loongarch64/Gresume.c b/src/loongarch64/Gresume.c
index 9a9c717e..66ce277c 100644
--- a/src/loongarch64/Gresume.c
+++ b/src/loongarch64/Gresume.c
@@ -65,6 +65,7 @@ loongarch64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg)
: "r" (uc->uc_mcontext.__gregs),
"r" (sp),
"r" (ra)
+ : "$t0", "$t1", "$t2", "memory"
);
}
else /* c->sigcontext_format == LOONGARCH64_SCF_LINUX_RT_SIGFRAME */
diff --git a/src/loongarch64/Gstep.c b/src/loongarch64/Gstep.c
index 221cc4f1..96789cba 100644
--- a/src/loongarch64/Gstep.c
+++ b/src/loongarch64/Gstep.c
@@ -36,8 +36,7 @@ loongarch64_handle_signal_frame (unw_cursor_t *cursor)
int i, ret;
if (unw_is_signal_frame (cursor)) {
- sc_addr = sp_addr + LINUX_SF_TRAMP_SIZE + sizeof (siginfo_t) +
- LINUX_UC_MCONTEXT_OFF;
+ sc_addr = sp_addr + sizeof (siginfo_t) + LINUX_UC_MCONTEXT_OFF;
} else {
c->sigcontext_format = LOONGARCH64_SCF_NONE;
return -UNW_EUNSPEC;
diff --git a/src/loongarch64/offsets.h b/src/loongarch64/offsets.h
index 9e46cff6..8657a119 100644
--- a/src/loongarch64/offsets.h
+++ b/src/loongarch64/offsets.h
@@ -4,19 +4,15 @@
/* Offsets for LoongArch64 Linux "ucontext_t": */
-/* First 24 bytes in sigframe are argument save space and padding for
-what used to be signal trampolines. Ref: arch/loongarch/kernel/signal.c */
-#define LINUX_SF_TRAMP_SIZE 0x18
-
# define LINUX_UC_FLAGS_OFF 0x0 /* offsetof(struct ucontext_t, __uc_flags) */
# define LINUX_UC_LINK_OFF 0x8 /* offsetof(struct ucontext_t, uc_link) */
# define LINUX_UC_STACK_OFF 0x10 /* offsetof(struct ucontext_t, uc_stack) */
# define LINUX_UC_SIGMASK_OFF 0x28 /* offsetof(struct ucontext_t, uc_sigmask) */
-# define LINUX_UC_MCONTEXT_OFF 0xc0 /* offsetof(struct ucontext_t, uc_mcontext) */
+# define LINUX_UC_MCONTEXT_OFF 0xb0 /* offsetof(struct ucontext_t, uc_mcontext) */
-# define LINUX_UC_MCONTEXT_PC 0xc0 /* offsetof(struct ucontext_t, uc_mcontext.__pc) */
-# define LINUX_UC_MCONTEXT_GREGS 0xc8 /* offsetof(struct ucontext_t, uc_mcontext.__gregs) */
-/* Offsets for AArch64 Linux "struct sigcontext": */
+# define LINUX_UC_MCONTEXT_PC 0xb0 /* offsetof(struct ucontext_t, uc_mcontext.__pc) */
+# define LINUX_UC_MCONTEXT_GREGS 0xb8 /* offsetof(struct ucontext_t, uc_mcontext.__gregs) */
+/* Offsets for LoongArch64 Linux "struct sigcontext": */
#define LINUX_SC_R0_OFF (LINUX_UC_MCONTEXT_GREGS - LINUX_UC_MCONTEXT_OFF)
#define LINUX_SC_R1_OFF (LINUX_SC_R0_OFF + 1*8)
#define LINUX_SC_R2_OFF (LINUX_SC_R0_OFF + 2*8)