bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* sigsegv.c: add OpenBSD/powerpc64 support
@ 2021-09-11 20:19 Christian Weisgerber
  2021-09-11 20:53 ` Paul Eggert
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Weisgerber @ 2021-09-11 20:19 UTC (permalink / raw)
  To: bug-gnulib

gnulib's sigsegv.c has support for OpenBSD on a number of architectures.
Currently, it treats powerpc64 the same as powerpc, but that is not
correct and will not compile.

Here's a patch to add powerp64 support:

diff b6bae60d83eda6b168368fa40f42ade9dfc86df0 /home/naddy/tmp/gnulib
blob - 998c82768cb6f7aa0a418551645c9910851ff9c8
file + lib/sigsegv.c
--- lib/sigsegv.c
+++ lib/sigsegv.c
@@ -511,8 +511,15 @@ int libsigsegv_version = LIBSIGSEGV_VERSION;
 
 #  define SIGSEGV_FAULT_STACKPOINTER  scp->sc_regs[29]
 
-# elif defined __powerpc__ || defined __powerpc64__
+# elif defined __powerpc64__
 
+/* See the definition of 'struct sigcontext' in
+   openbsd-src/sys/arch/powerpc64/include/signal.h.  */
+
+#  define SIGSEGV_FAULT_STACKPOINTER  scp->sc_sp
+
+# elif defined __powerpc__
+
 /* See the definition of 'struct sigcontext' and 'struct trapframe' in
    openbsd-src/sys/arch/powerpc/include/signal.h.  */
 
-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de


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

* Re: sigsegv.c: add OpenBSD/powerpc64 support
  2021-09-11 20:19 sigsegv.c: add OpenBSD/powerpc64 support Christian Weisgerber
@ 2021-09-11 20:53 ` Paul Eggert
  2021-09-11 22:42   ` Christian Weisgerber
  2021-09-11 23:01   ` Bruno Haible
  0 siblings, 2 replies; 6+ messages in thread
From: Paul Eggert @ 2021-09-11 20:53 UTC (permalink / raw)
  To: Christian Weisgerber; +Cc: Gnulib bugs

[-- Attachment #1: Type: text/plain, Size: 553 bytes --]

On 9/11/21 1:19 PM, Christian Weisgerber wrote:
> +/* See the definition of 'struct sigcontext' in
> +   openbsd-src/sys/arch/powerpc64/include/signal.h.  */
> +
> +#  define SIGSEGV_FAULT_STACKPOINTER  scp->sc_sp

Thanks for the heads-up. What you suggested looks safe so I installed 
the attached patch into Gnulib master on savannah. The "(tiny change)" 
means the change is so small we needn't worry about copyright papers.

Bruno may eventually have a better patch in mind.

Are similar changes needed for other OpenBSD architectures?

[-- Attachment #2: 0001-sigsegv-port-to-OpenBSD-6.8-powerpc64.patch --]
[-- Type: text/x-patch, Size: 2077 bytes --]

From aa35e17ac6d4749c017eea4b1920903277ce3f69 Mon Sep 17 00:00:00 2001
From: Christian Weisgerber <naddy@mips.inka.de>
Date: Sat, 11 Sep 2021 13:51:13 -0700
Subject: [PATCH] sigsegv: port to OpenBSD 6.8+ powerpc64
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lib/sigsegv.c (SIGSEGV_FAULT_STACKPOINTER):
Special case for __OpenBSD__ && __powerpc64__, needed due to:
https://github.com/openbsd/src/commit/5e649a8714ba05cf482011b7b7d1e5437b7c17db
which is part of the oldest currently-supported OpenBSD (6.8),
so we needn’t worry about older versions.
---
 ChangeLog     | 9 +++++++++
 lib/sigsegv.c | 9 ++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index a7fd469f4..b9795d658 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2021-09-11  Christian Weisgerber  <naddy@mips.inka.de>  (tiny change)
+
+	sigsegv: port to OpenBSD 6.8+ powerpc64
+	* lib/sigsegv.c (SIGSEGV_FAULT_STACKPOINTER):
+	Special case for __OpenBSD__ && __powerpc64__, needed due to:
+	https://github.com/openbsd/src/commit/5e649a8714ba05cf482011b7b7d1e5437b7c17db
+	which is part of the oldest currently-supported OpenBSD (6.8),
+	so we needn’t worry about older versions.
+
 2021-09-09  Pádraig Brady  <P@draigBrady.com>
 
 	maintainer-makefile: add 'can' to sc_prohibit_doubled_word
diff --git a/lib/sigsegv.c b/lib/sigsegv.c
index 998c82768..347b42644 100644
--- a/lib/sigsegv.c
+++ b/lib/sigsegv.c
@@ -511,7 +511,14 @@ int libsigsegv_version = LIBSIGSEGV_VERSION;
 
 #  define SIGSEGV_FAULT_STACKPOINTER  scp->sc_regs[29]
 
-# elif defined __powerpc__ || defined __powerpc64__
+# elif defined __powerpc64__
+
+/* See the definition of 'struct sigcontext' in
+   openbsd-src/sys/arch/powerpc64/include/signal.h.  */
+
+#  define SIGSEGV_FAULT_STACKPOINTER  scp->sc_sp
+
+# elif defined __powerpc__
 
 /* See the definition of 'struct sigcontext' and 'struct trapframe' in
    openbsd-src/sys/arch/powerpc/include/signal.h.  */
-- 
2.30.2


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

* Re: sigsegv.c: add OpenBSD/powerpc64 support
  2021-09-11 20:53 ` Paul Eggert
@ 2021-09-11 22:42   ` Christian Weisgerber
  2021-09-11 23:01   ` Bruno Haible
  1 sibling, 0 replies; 6+ messages in thread
From: Christian Weisgerber @ 2021-09-11 22:42 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Gnulib bugs

Paul Eggert:

> Are similar changes needed for other OpenBSD architectures?

No.  The impetus for this was that the latest release of GNU grep
failed to compile specifically on powerpc64.

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de


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

* Re: sigsegv.c: add OpenBSD/powerpc64 support
  2021-09-11 20:53 ` Paul Eggert
  2021-09-11 22:42   ` Christian Weisgerber
@ 2021-09-11 23:01   ` Bruno Haible
  2021-09-13 19:37     ` Christian Weisgerber
  1 sibling, 1 reply; 6+ messages in thread
From: Bruno Haible @ 2021-09-11 23:01 UTC (permalink / raw)
  To: Christian Weisgerber; +Cc: Paul Eggert, bug-gnulib

Thanks, Christian.

Paul Eggert wrote:
> Bruno may eventually have a better patch in mind.

The patch looks right; it is consistent with
https://cvsweb.openbsd.org/src/sys/arch/powerpc64/include/signal.h?rev=1.5&content-type=text/x-cvsweb-markup .
But has it also been tested? The test procedure is to create a testdir of
this gnulib module:

  $ ./gnulib-tool --create-testdir --dir=testdir-sigsegv --single-configure sigsegv

then transfer this directory 'testdir-sigsegv' to an OpenBSD/powerpc64
machine, and there
  $ ./configure CPPFLAGS=-Wall
  $ gmake
  $ gmake check
Which tests pass, which tests fail?

Bruno





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

* Re: sigsegv.c: add OpenBSD/powerpc64 support
  2021-09-11 23:01   ` Bruno Haible
@ 2021-09-13 19:37     ` Christian Weisgerber
  2021-09-13 23:12       ` Bruno Haible
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Weisgerber @ 2021-09-13 19:37 UTC (permalink / raw)
  To: Bruno Haible; +Cc: Paul Eggert, bug-gnulib

Bruno Haible:

> The patch looks right; it is consistent with
> https://cvsweb.openbsd.org/src/sys/arch/powerpc64/include/signal.h?rev=1.5&content-type=text/x-cvsweb-markup .
> But has it also been tested? The test procedure is to create a testdir of
> this gnulib module:
> [...]
> Which tests pass, which tests fail?

All tests pass:

make  check-TESTS
PASS: test-intprops
PASS: test-inttypes
PASS: test-limits-h
PASS: test-sigsegv-catch-segv1
PASS: test-sigsegv-catch-segv2
PASS: test-sigsegv-catch-stackoverflow1
PASS: test-sigsegv-catch-stackoverflow2
PASS: test-stdalign
PASS: test-stdbool
PASS: test-stddef
PASS: test-stdint
PASS: test-stdlib
PASS: test-sys_types
PASS: test-init.sh
PASS: test-unistd
PASS: test-verify
PASS: test-verify.sh
PASS: test-wchar
============================================================================
Testsuite summary for dummy 0
============================================================================
# TOTAL: 18
# PASS:  18
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de


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

* Re: sigsegv.c: add OpenBSD/powerpc64 support
  2021-09-13 19:37     ` Christian Weisgerber
@ 2021-09-13 23:12       ` Bruno Haible
  0 siblings, 0 replies; 6+ messages in thread
From: Bruno Haible @ 2021-09-13 23:12 UTC (permalink / raw)
  To: Christian Weisgerber; +Cc: Paul Eggert, bug-gnulib

Christian Weisgerber wrote:
> PASS: test-sigsegv-catch-segv1
> PASS: test-sigsegv-catch-segv2
> PASS: test-sigsegv-catch-stackoverflow1
> PASS: test-sigsegv-catch-stackoverflow2

Cool. Thanks! I've added the same support also to libsigsegv:
https://git.savannah.gnu.org/gitweb/?p=libsigsegv.git;a=commitdiff;h=44b8269a91ed37fec4543dd6716e583a2a6450e7

Bruno





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

end of thread, other threads:[~2021-09-13 23:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-11 20:19 sigsegv.c: add OpenBSD/powerpc64 support Christian Weisgerber
2021-09-11 20:53 ` Paul Eggert
2021-09-11 22:42   ` Christian Weisgerber
2021-09-11 23:01   ` Bruno Haible
2021-09-13 19:37     ` Christian Weisgerber
2021-09-13 23:12       ` Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).