diff mbox series

[uclibc-ng-devel] x86: Fix __libc_sigaction implementation.

Message ID 20240420103352.1861425-1-dm.chestnykh@gmail.com
State Accepted
Headers show
Series [uclibc-ng-devel] x86: Fix __libc_sigaction implementation. | expand

Commit Message

Dmitry Chestnykh April 20, 2024, 10:33 a.m. UTC
For x86 we have to copy only mask, handler and flags.
We haven't set SA_RESTORER bit in sa_flags anyway.
This patch fixes multiple test failures on x86.
Also we have to build uClibc with FP for x86 because
without FP NPTL and libgcc code cannot properly unwind
the stack during asynchronous cancellation of system calls.

Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
---
 Rules.mak                           | 5 +++--
 libc/sysdeps/linux/i386/sigaction.c | 7 ++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

Comments

Waldemar Brodkorb April 21, 2024, 9:30 a.m. UTC | #1
Hi Dmitry,
Dmitry Chestnykh wrote,

> For x86 we have to copy only mask, handler and flags.
> We haven't set SA_RESTORER bit in sa_flags anyway.
> This patch fixes multiple test failures on x86.
> Also we have to build uClibc with FP for x86 because
> without FP NPTL and libgcc code cannot properly unwind
> the stack during asynchronous cancellation of system calls.
> 
> Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>

Great! Committed and pushed,
 Waldemar
diff mbox series

Patch

diff --git a/Rules.mak b/Rules.mak
index f2e5791e3..2c2c87928 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -336,8 +336,6 @@  $(eval $(call check-gcc-var,-ffunction-sections))
 
 # Some nice CPU specific optimizations
 ifeq ($(TARGET_ARCH),i386)
-$(eval $(call check-gcc-var,-fomit-frame-pointer))
-	OPTIMIZATION += $(CFLAG_-fomit-frame-pointer)
 
 ifeq ($(CONFIG_386)$(CONFIG_486)$(CONFIG_586),y)
 	# TODO: Change this to a gcc version check.  This bug
@@ -662,6 +660,9 @@  endif
 ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
 CFLAGS += $(call qstrip,$(UCLIBC_EXTRA_CFLAGS))
 endif
+ifeq ($(TARGET_ARCH),i386)
+CFLAGS += -fno-omit-frame-pointer
+endif
 ifneq ($(strip $(UCLIBC_EXTRA_LDFLAGS)),"")
 LDFLAGS += $(call qstrip,$(UCLIBC_EXTRA_LDFLAGS))
 endif
diff --git a/libc/sysdeps/linux/i386/sigaction.c b/libc/sysdeps/linux/i386/sigaction.c
index cf6daa787..515ef99f2 100644
--- a/libc/sysdeps/linux/i386/sigaction.c
+++ b/libc/sysdeps/linux/i386/sigaction.c
@@ -31,15 +31,16 @@ 
 extern void restore_rt(void) __asm__ ("__restore_rt") attribute_hidden;
 extern void restore(void) __asm__ ("__restore") attribute_hidden;
 
-/* If ACT is not NULL, change the action for SIG to *ACT.
+/* If ACT is not NULL, change mask, handler and flags for SIG to ACT's
    If OACT is not NULL, put the old action for SIG in *OACT.  */
 int __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
 {
 	struct sigaction kact;
 
 	if (act) {
-		memcpy(&kact, act, sizeof(kact));
-		kact.sa_flags |= SA_RESTORER;
+		memcpy(&kact.sa_mask, &act->sa_mask, sizeof(sigset_t));
+		kact.sa_handler = act->sa_handler;
+		kact.sa_flags = act->sa_flags;
 		kact.sa_restorer = (act->sa_flags & SA_SIGINFO) ? &restore_rt : &restore;
 		act = &kact;
 	}