All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [git commit branch/2022.02.x] package/diffutils: Fix build on ppc32 with musl
@ 2022-06-09 11:24 Peter Korsgaard
  0 siblings, 0 replies; only message in thread
From: Peter Korsgaard @ 2022-06-09 11:24 UTC (permalink / raw)
  To: buildroot

commit: https://git.buildroot.net/buildroot/commit/?id=fab913fec8ce7091c5fec6b93635687303b9ccd1
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2022.02.x

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 diffutils).

Fixes:

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

Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
(cherry picked from commit 2bee0f34598d64a983a30ab7999bf4305f957377)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
 ...-support-for-Linux-PowerPC-32-bit-with-mu.patch | 58 ++++++++++++++++++++++
 1 file changed, 58 insertions(+)

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 0000000000..16e0941f6c
--- /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
+
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-09 11:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-09 11:24 [Buildroot] [git commit branch/2022.02.x] package/diffutils: Fix build on ppc32 with musl Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.