diff mbox series

package/diffutils: Fix build on ppc32 with musl

Message ID 20220606075149.1548504-1-joel@jms.id.au
State Accepted
Headers show
Series package/diffutils: Fix build on ppc32 with musl | expand

Commit Message

Joel Stanley June 6, 2022, 7:51 a.m. UTC
sigsegv.c: In function 'sigsegv_handler':
 sigsegv.c:225:75: error: 'mcontext_t' has no member named 'uc_regs';
 did you mean 'gregs'?

  ((ucontext_t *) ucp)->uc_mcontext.uc_regs->gregs[1]

Musl defines pt_regs differently to glibc. Backport a patch from
upstream gnulib (the source for this file in findutils).

Fixes:

 http://autobuild.buildroot.net/results/1b40146436eb2b3500d0d8faef96b3374f8e5cda/

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 ...ort-for-Linux-PowerPC-32-bit-with-mu.patch | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 package/diffutils/0005-sigsegv-Add-support-for-Linux-PowerPC-32-bit-with-mu.patch

Comments

Peter Korsgaard June 6, 2022, 9:31 a.m. UTC | #1
>>>>> "Joel" == Joel Stanley <joel@jms.id.au> writes:

 >  sigsegv.c: In function 'sigsegv_handler':
 >  sigsegv.c:225:75: error: 'mcontext_t' has no member named 'uc_regs';
 >  did you mean 'gregs'?

 >   ((ucontext_t *) ucp)->uc_mcontext.uc_regs->gregs[1]

 > Musl defines pt_regs differently to glibc. Backport a patch from
 > upstream gnulib (the source for this file in findutils).

s/findutils/diffutils/

Committed, thanks.
Peter Korsgaard June 9, 2022, 11:24 a.m. UTC | #2
>>>>> "Joel" == Joel Stanley <joel@jms.id.au> writes:

 >  sigsegv.c: In function 'sigsegv_handler':
 >  sigsegv.c:225:75: error: 'mcontext_t' has no member named 'uc_regs';
 >  did you mean 'gregs'?

 >   ((ucontext_t *) ucp)->uc_mcontext.uc_regs->gregs[1]

 > Musl defines pt_regs differently to glibc. Backport a patch from
 > upstream gnulib (the source for this file in findutils).

 > Fixes:

 >  http://autobuild.buildroot.net/results/1b40146436eb2b3500d0d8faef96b3374f8e5cda/

 > Signed-off-by: Joel Stanley <joel@jms.id.au>

Committed to 2022.02.x, thanks.
diff mbox series

Patch

diff --git a/package/diffutils/0005-sigsegv-Add-support-for-Linux-PowerPC-32-bit-with-mu.patch b/package/diffutils/0005-sigsegv-Add-support-for-Linux-PowerPC-32-bit-with-mu.patch
new file mode 100644
index 000000000000..16e0941f6c2a
--- /dev/null
+++ b/package/diffutils/0005-sigsegv-Add-support-for-Linux-PowerPC-32-bit-with-mu.patch
@@ -0,0 +1,58 @@ 
+From 6f2f006185cdeeda997d19d651379bfc6887e394 Mon Sep 17 00:00:00 2001
+From: Joel Stanley <joel@jms.id.au>
+Date: Mon, 6 Jun 2022 17:14:12 +0930
+Subject: [PATCH] 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.
+
+Backported from http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=2d830e4a792fcd9f614ed08a7f18584b8b21d23b
+Signed-off-by: Joel Stanley <joel@jms.id.au>
+---
+ lib/sigsegv.c | 25 +++++++++++++++++++++----
+ 1 file changed, 21 insertions(+), 4 deletions(-)
+
+diff --git a/lib/sigsegv.c b/lib/sigsegv.c
+index da70ffa5fda1..da64d7d0b617 100644
+--- a/lib/sigsegv.c
++++ b/lib/sigsegv.c
+@@ -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
+ 
+-- 
+2.35.1
+