Package: diffutils
Version: 3.8-1
Severity: wishlist
Tags: patch
User: [email protected]
Usertags: loongarch64
Dear diffutils maintainers,
I have defined SIGSEGV_FAULT_STACKPOINTER for loongarch.
Please consider the patch attached.
thanks,
Dandan Zhang
diff --git a/lib/sigsegv.c b/lib/sigsegv.c
index 998c827..6d9287e 100644
--- a/lib/sigsegv.c
+++ b/lib/sigsegv.c
@@ -168,6 +168,18 @@ int libsigsegv_version = LIBSIGSEGV_VERSION;
because $bsp and $bspstore never differ by more than ca. 1 KB. */
# define SIGSEGV_FAULT_BSP_POINTER ((ucontext_t *) ucp)->uc_mcontext.sc_ar_bsp
+# elif defined __loongarch__ || defined __loongarch64
+
+/* See glibc/sysdeps/unix/sysv/linux/loongarch/sys/ucontext.h
+ and the definition of GET_STACK in
+ glibc/sysdeps/unix/sysv/linux/loongarch/sigcontextinfo.h.
+ Note that the 'mcontext_t' defined in
+ glibc/sysdeps/unix/sysv/linux/loongarch/sys/ucontext.h
+ and the 'struct sigcontext' defined in <asm/sigcontext.h>
+ are effectively the same. */
+
+# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.__gregs[LARCH_REG_SP]
+
# elif defined __m68k__
/* See glibc/sysdeps/unix/sysv/linux/m68k/sys/ucontext.h