0001-Add-support-for-Linux-PowerPC-32-bit-with-musl-libc.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. From a6ff69873110c0a8ba6f7fd90532dbc11224828c Mon Sep 17 00:00:00 2001
  2. From: Bruno Haible <bruno@clisp.org>
  3. Date: Sun, 13 Mar 2022 15:04:06 +0100
  4. Subject: [PATCH] Add support for Linux/PowerPC (32-bit) with musl libc.
  5. Reported by Khem Raj <raj.khem@gmail.com> in
  6. <https://lists.gnu.org/archive/html/m4-patches/2022-03/msg00000.html>.
  7. * autogen.sh: Copy also musl.m4.
  8. * configure.ac: Invoke gl_MUSL_LIBC.
  9. * src/fault-linux-powerpc.h (SIGSEGV_FAULT_STACKPOINTER): In the 32-bit
  10. case, handle musl libc differently.
  11. * NEWS: Mention it.
  12. Upstream: https://git.savannah.gnu.org/gitweb/?p=libsigsegv.git;a=commit;h=a6ff69873110c0a8ba6f7fd90532dbc11224828c
  13. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  14. ---
  15. ChangeLog | 11 +++++++++++
  16. NEWS | 4 ++++
  17. autogen.sh | 3 ++-
  18. configure.ac | 2 ++
  19. src/fault-linux-powerpc.h | 27 ++++++++++++++++++++++-----
  20. 5 files changed, 41 insertions(+), 6 deletions(-)
  21. diff --git a/ChangeLog b/ChangeLog
  22. index c52b227..7c0a8fa 100644
  23. --- a/ChangeLog
  24. +++ b/ChangeLog
  25. @@ -1,3 +1,14 @@
  26. +2022-03-13 Bruno Haible <bruno@clisp.org>
  27. +
  28. + Add support for Linux/PowerPC (32-bit) with musl libc.
  29. + Reported by Khem Raj <raj.khem@gmail.com> in
  30. + <https://lists.gnu.org/archive/html/m4-patches/2022-03/msg00000.html>.
  31. + * autogen.sh: Copy also musl.m4.
  32. + * configure.ac: Invoke gl_MUSL_LIBC.
  33. + * src/fault-linux-powerpc.h (SIGSEGV_FAULT_STACKPOINTER): In the 32-bit
  34. + case, handle musl libc differently.
  35. + * NEWS: Mention it.
  36. +
  37. 2022-01-07 Bruno Haible <bruno@clisp.org>
  38. Prepare for version 2.14.
  39. diff --git a/NEWS b/NEWS
  40. index 4d012f8..82cc0f4 100644
  41. --- a/NEWS
  42. +++ b/NEWS
  43. @@ -1,3 +1,7 @@
  44. +New in 2.15:
  45. +
  46. +* Added support for Linux/PowerPC (32-bit) with musl libc.
  47. +
  48. New in 2.14:
  49. * Added support for 64-bit Cygwin.
  50. diff --git a/configure.ac b/configure.ac
  51. index e87f13b..164786f 100644
  52. --- a/configure.ac
  53. +++ b/configure.ac
  54. @@ -75,6 +75,8 @@ AC_MSG_RESULT([$sv_cv_host])
  55. PLATFORM="$sv_cv_host"
  56. AC_SUBST([PLATFORM])
  57. +gl_MUSL_LIBC
  58. +
  59. dnl ========================== Done with PLATFORM ==========================
  60. diff --git a/src/fault-linux-powerpc.h b/src/fault-linux-powerpc.h
  61. index cba6ea7..b3f922a 100644
  62. --- a/src/fault-linux-powerpc.h
  63. +++ b/src/fault-linux-powerpc.h
  64. @@ -1,5 +1,5 @@
  65. /* Fault handler information. Linux/PowerPC version when it supports POSIX.
  66. - Copyright (C) 2002, 2009, 2017 Bruno Haible <bruno@clisp.org>
  67. + Copyright (C) 2002, 2009, 2017, 2022 Bruno Haible <bruno@clisp.org>
  68. This program is free software: you can redistribute it and/or modify
  69. it under the terms of the GNU General Public License as published by
  70. @@ -28,10 +28,27 @@
  71. #if defined(__powerpc64__) || defined(_ARCH_PPC64) /* 64-bit */
  72. # define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gp_regs[1]
  73. #else /* 32-bit */
  74. -/* both should be equivalent */
  75. -# if 0
  76. -# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.regs->gpr[1]
  77. +# if MUSL_LIBC
  78. +/* musl libc has a different structure of ucontext_t in
  79. + musl/arch/powerpc/bits/signal.h. */
  80. +/* The glibc comments say:
  81. + "Different versions of the kernel have stored the registers on signal
  82. + delivery at different offsets from the ucontext struct. Programs should
  83. + thus use the uc_mcontext.uc_regs pointer to find where the registers are
  84. + actually stored." */
  85. +# if 0
  86. +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gregs[1]
  87. +# else
  88. +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_regs->gregs[1]
  89. +# endif
  90. # else
  91. -# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.uc_regs->gregs[1]
  92. +/* Assume the structure of ucontext_t in
  93. + glibc/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h. */
  94. +/* Because of the union, both definitions should be equivalent. */
  95. +# if 0
  96. +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.regs->gpr[1]
  97. +# else
  98. +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.uc_regs->gregs[1]
  99. +# endif
  100. # endif
  101. #endif
  102. --
  103. 2.17.1