All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/libsigsegv: fix macro expansion error for RISC-V with musl
@ 2019-10-25  9:56 Mark Corbin
  2019-10-25 19:43 ` Thomas Petazzoni
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Corbin @ 2019-10-25  9:56 UTC (permalink / raw)
  To: buildroot

The expansion of the SIGSEGV_FAULT_STACKPOINTER macro fails when
building for RISC-V with musl because REG_SP is not defined (it is
defined for glibc). This patch just replaces REG_SP with the
numerical register offset (which is 2 for the stack pointer).

Fixes:
  http://autobuild.buildroot.net/results/8d6cade2562404b9800736a3b9a2beada98bda88

Signed-off-by: Mark Corbin <mark.corbin@embecosm.com>
---
 ...ion-error-when-building-for-RISC-V-w.patch | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 package/libsigsegv/0005-Fix-macro-expansion-error-when-building-for-RISC-V-w.patch

diff --git a/package/libsigsegv/0005-Fix-macro-expansion-error-when-building-for-RISC-V-w.patch b/package/libsigsegv/0005-Fix-macro-expansion-error-when-building-for-RISC-V-w.patch
new file mode 100644
index 0000000000..6906e04b1d
--- /dev/null
+++ b/package/libsigsegv/0005-Fix-macro-expansion-error-when-building-for-RISC-V-w.patch
@@ -0,0 +1,29 @@
+From 3da9e4a8aea252143ab567678722c739793cfeb7 Mon Sep 17 00:00:00 2001
+From: Mark Corbin <mark.corbin@embecosm.com>
+Date: Fri, 25 Oct 2019 10:16:54 +0100
+Subject: [PATCH] Fix macro expansion error when building for RISC-V with
+ musl
+
+The expansion of the SIGSEGV_FAULT_STACKPOINTER macro fails when
+building for RISC-V with musl because REG_SP is not defined (it is
+defined for glibc). This patch just replaces REG_SP with the
+numerical register offset (which is 2 for the stack pointer).
+
+Signed-off-by: Mark Corbin <mark.corbin@embecosm.com>
+---
+ src/fault-linux-riscv64.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/fault-linux-riscv64.h b/src/fault-linux-riscv64.h
+index 14831bf..7fee4d3 100644
+--- a/src/fault-linux-riscv64.h
++++ b/src/fault-linux-riscv64.h
+@@ -26,4 +26,4 @@
+    glibc/sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h
+    start with the same block of 32 general-purpose registers.  */
+ 
+-#define SIGSEGV_FAULT_STACKPOINTER  ((ucontext_t *) ucp)->uc_mcontext.__gregs[REG_SP]
++#define SIGSEGV_FAULT_STACKPOINTER  ((ucontext_t *) ucp)->uc_mcontext.__gregs[2]
+-- 
+2.19.1
+
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH 1/1] package/libsigsegv: fix macro expansion error for RISC-V with musl
  2019-10-25  9:56 [Buildroot] [PATCH 1/1] package/libsigsegv: fix macro expansion error for RISC-V with musl Mark Corbin
@ 2019-10-25 19:43 ` Thomas Petazzoni
  2019-10-26  8:01   ` Mark Corbin
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2019-10-25 19:43 UTC (permalink / raw)
  To: buildroot

On Fri, 25 Oct 2019 10:56:05 +0100
Mark Corbin <mark.corbin@embecosm.com> wrote:

> The expansion of the SIGSEGV_FAULT_STACKPOINTER macro fails when
> building for RISC-V with musl because REG_SP is not defined (it is
> defined for glibc). This patch just replaces REG_SP with the
> numerical register offset (which is 2 for the stack pointer).

REG_SP is defined in musl in:

  https://git.musl-libc.org/cgit/musl/tree/arch/riscv64/bits/reg.h

So I'm not sure I'm following the reasoning here.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH 1/1] package/libsigsegv: fix macro expansion error for RISC-V with musl
  2019-10-25 19:43 ` Thomas Petazzoni
@ 2019-10-26  8:01   ` Mark Corbin
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Corbin @ 2019-10-26  8:01 UTC (permalink / raw)
  To: buildroot

Hello Thomas

On 25/10/2019 20:43, Thomas Petazzoni wrote:
> On Fri, 25 Oct 2019 10:56:05 +0100
> Mark Corbin <mark.corbin@embecosm.com> wrote:
>
>> The expansion of the SIGSEGV_FAULT_STACKPOINTER macro fails when
>> building for RISC-V with musl because REG_SP is not defined (it is
>> defined for glibc). This patch just replaces REG_SP with the
>> numerical register offset (which is 2 for the stack pointer).
> REG_SP is defined in musl in:
>
>   https://git.musl-libc.org/cgit/musl/tree/arch/riscv64/bits/reg.h
>
> So I'm not sure I'm following the reasoning here.

There are register definitions in reg.h, but these are not the ones used
by the signal header files in musl (arch/<build arch>/bits/signal.h). If
you want to index the registers array in the ucontext_t or mcontext_t
structures using a register name it needs to be defined at the top of
bits/signal.h (see the musl i386, m68k, x32 and x86_64 architectures).
Alternatively, for architectures that do not define register names in
the musl signal.h file, the registers array is indexed in libsigsegv
using a numeric offset (see libsigsegv-2.12/src/fault-linux-mips.h for
example).

There are two options to fix the current libsigsegv build issue for
RISC-V with musl (REG_SP undefined), either a) patch musl to add a
definition for REG_SP to signal.h or b) change REG_SP to a numeric value
of 2 in libsigsegv-2.12/src/fault-linux-riscv64.h (as proposed by this
patch).


Mark

-- 
-- 
Mark Corbin
Embecosm Ltd.
https://www.embecosm.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-26  8:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25  9:56 [Buildroot] [PATCH 1/1] package/libsigsegv: fix macro expansion error for RISC-V with musl Mark Corbin
2019-10-25 19:43 ` Thomas Petazzoni
2019-10-26  8:01   ` Mark Corbin

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.