2
1

0005-sigsegv-Add-support-for-Linux-PowerPC-32-bit-with-mu.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From 6f2f006185cdeeda997d19d651379bfc6887e394 Mon Sep 17 00:00:00 2001
  2. From: Joel Stanley <joel@jms.id.au>
  3. Date: Mon, 6 Jun 2022 17:14:12 +0930
  4. Subject: [PATCH] sigsegv: Add support for Linux/PowerPC (32-bit) with musl
  5. libc. Reported by Khem Raj <raj.khem@gmail.com> in
  6. <https://lists.gnu.org/archive/html/m4-patches/2022-03/msg00000.html>.
  7. * src/sigsegv.c (SIGSEGV_FAULT_STACKPOINTER): In the Linux/PowerPC
  8. 32-bit case, handle musl libc differently.
  9. * modules/sigsegv (Files): Add m4/musl.m4.
  10. (configure.ac): Invoke gl_MUSL_LIBC.
  11. Backported from http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=2d830e4a792fcd9f614ed08a7f18584b8b21d23b
  12. Signed-off-by: Joel Stanley <joel@jms.id.au>
  13. ---
  14. lib/sigsegv.c | 25 +++++++++++++++++++++----
  15. 1 file changed, 21 insertions(+), 4 deletions(-)
  16. diff --git a/lib/sigsegv.c b/lib/sigsegv.c
  17. index da70ffa5fda1..da64d7d0b617 100644
  18. --- a/lib/sigsegv.c
  19. +++ b/lib/sigsegv.c
  20. @@ -227,11 +227,28 @@ int libsigsegv_version = LIBSIGSEGV_VERSION;
  21. # if defined __powerpc64__ || defined __powerpc64_elfv2__ /* 64-bit */
  22. # define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gp_regs[1]
  23. # else /* 32-bit */
  24. -/* both should be equivalent */
  25. -# if 0
  26. -# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.regs->gpr[1]
  27. +# if MUSL_LIBC
  28. +/* musl libc has a different structure of ucontext_t in
  29. + musl/arch/powerpc/bits/signal.h. */
  30. +/* The glibc comments say:
  31. + "Different versions of the kernel have stored the registers on signal
  32. + delivery at different offsets from the ucontext struct. Programs should
  33. + thus use the uc_mcontext.uc_regs pointer to find where the registers are
  34. + actually stored." */
  35. +# if 0
  36. +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gregs[1]
  37. +# else
  38. +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_regs->gregs[1]
  39. +# endif
  40. # else
  41. -# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.uc_regs->gregs[1]
  42. +/* Assume the structure of ucontext_t in
  43. + glibc/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h. */
  44. +/* Because of the union, both definitions should be equivalent. */
  45. +# if 0
  46. +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.regs->gpr[1]
  47. +# else
  48. +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.uc_regs->gregs[1]
  49. +# endif
  50. # endif
  51. # endif
  52. --
  53. 2.35.1