1
0
mirror of https://https.git.savannah.gnu.org/git/gnulib.git synced 2026-05-13 07:03:33 +00:00

sigsegv: Add support for Linux/PowerPC (32-bit) with musl libc.

Reported by Khem Raj <raj.khem@gmail.com> in
<https://lists.gnu.org/archive/html/m4-patches/2022-03/msg00000.html>.

* src/sigsegv.c (SIGSEGV_FAULT_STACKPOINTER): In the Linux/PowerPC
32-bit case, handle musl libc differently.
* modules/sigsegv (Files): Add m4/musl.m4.
(configure.ac): Invoke gl_MUSL_LIBC.
This commit is contained in:
Bruno Haible
2022-03-13 15:12:46 +01:00
parent 9db7e04d15
commit 2d830e4a79
3 changed files with 34 additions and 4 deletions

View File

@@ -227,11 +227,28 @@ int libsigsegv_version = LIBSIGSEGV_VERSION;
# if defined __powerpc64__ || defined __powerpc64_elfv2__ /* 64-bit */
# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gp_regs[1]
# else /* 32-bit */
/* both should be equivalent */
# if 0
# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.regs->gpr[1]
# if MUSL_LIBC
/* musl libc has a different structure of ucontext_t in
musl/arch/powerpc/bits/signal.h. */
/* The glibc comments say:
"Different versions of the kernel have stored the registers on signal
delivery at different offsets from the ucontext struct. Programs should
thus use the uc_mcontext.uc_regs pointer to find where the registers are
actually stored." */
# if 0
# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gregs[1]
# else
# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_regs->gregs[1]
# endif
# else
# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.uc_regs->gregs[1]
/* Assume the structure of ucontext_t in
glibc/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h. */
/* Because of the union, both definitions should be equivalent. */
# if 0
# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.regs->gpr[1]
# else
# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.uc_regs->gregs[1]
# endif
# endif
# endif