From patchwork Sat Apr 20 10:33:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Chestnykh X-Patchwork-Id: 1925842 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=JEM0cqem; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org) Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VM7FQ3C7Xz1yZP for ; Sat, 20 Apr 2024 20:35:19 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id F07813528296; Sat, 20 Apr 2024 12:35:01 +0200 (CEST) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=JEM0cqem; dkim-atps=neutral Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) by helium.openadk.org (Postfix) with ESMTPS id 5ABAF3528262 for ; Sat, 20 Apr 2024 12:32:49 +0200 (CEST) Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2d9f829d398so6720561fa.0 for ; Sat, 20 Apr 2024 03:32:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713609167; x=1714213967; darn=uclibc-ng.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=N9i3a0uki3De7kY3Ci6zPS8zyE0tw7sF1Bw8FM33EpA=; b=JEM0cqem6pRlC2QZB8NK2S6yOY3sDjFmT94Z9Bq9k3NuZV1Vd95KnQEVeYsfLzqtZa EE0pfW4OqyTfHmvAnzVA7493xJFeV7ct/6PugEmwtqW0IrPRKg+EQ5R+J5nOUgTdDYoY vf4B6mXMSpfP1/GdyGmXmhpsj6uuBrFJ5gnqKPf5YTxU/OZN1nC6bYlPq1s5a8NuJtDc Ot1iZlHNx0In9+9JuJcBfht64WB9man/+qH5T1UlaXfL8rQ1eGmDj3XjHsWtkfDnxtLh ZybCRgdmOgnqVNAE8URjKrmKhQJHNbG/cZOxRXP+O1+JaaOP+rX0SjvSoXvZIoRsBuYz xz+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713609167; x=1714213967; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=N9i3a0uki3De7kY3Ci6zPS8zyE0tw7sF1Bw8FM33EpA=; b=ARRIC8x3P1BgUTTQ+Jb1uZV1if+XxWUdPwpKLq606Y/4jOnJKW6ibNPlQK3C+OwIhF yGUz/L3exejCebWC/WnW9DJmgEWgghDQpQFEBMif5q3lyXLDFHIVjIulcegiI/Pdu3ov fpQBpZx+vnfsk3XUvpSxbNiVnp72xTbv8KPkotKgw/RvfEY3CxqNuVjB0OmBOwnQ70te 6HeF0ZNUsAtPzDVFK4fSOFPS1IcKFGPG1CC4KAVc3r1ODqWZtQCQ21r67RdiEop/MYKF gVxUuZhmKa3xLPT1ourRmYanhca52twkPOM1FgJzdv1MnqKC8dAxhUwXZhVh50TJY6Dj TNTg== X-Gm-Message-State: AOJu0Yxkv0t7BLUp6UJDOIBnJ+9KoVOpny8aJpRCcs4KMFSYZRURNGnz 9dYQwxfUhthu3nnn+EcA6wSk3FnMt6ScIn/mfUee9BJJp56GRwbmLpvAow== X-Google-Smtp-Source: AGHT+IFT/4oRv+4SJO3aYo26lqw/ANEAJKldY00X8j24hRRR7D8QmPrfIR4v/QE4vJ72REtXSEZKxw== X-Received: by 2002:a19:5e4d:0:b0:516:ced5:3af9 with SMTP id z13-20020a195e4d000000b00516ced53af9mr3049720lfi.5.1713609166684; Sat, 20 Apr 2024 03:32:46 -0700 (PDT) Received: from localhost.localdomain ([2a00:1370:817a:d2b8:1bd6:8ee:5522:2a21]) by smtp.gmail.com with ESMTPSA id e9-20020a196909000000b00516d282df53sm1106643lfc.253.2024.04.20.03.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 03:32:46 -0700 (PDT) From: Dmitry Chestnykh To: devel@uclibc-ng.org Date: Sat, 20 Apr 2024 13:33:52 +0300 Message-ID: <20240420103352.1861425-1-dm.chestnykh@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Message-ID-Hash: I55X63ND4XWJAV6TTHN5MYM6GJVMSDKY X-Message-ID-Hash: I55X63ND4XWJAV6TTHN5MYM6GJVMSDKY X-MailFrom: dm.chestnykh@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Dmitry Chestnykh X-Mailman-Version: 3.3.3 Precedence: list Subject: [uclibc-ng-devel] [PATCH] x86: Fix __libc_sigaction implementation. List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- Rules.mak | 5 +++-- libc/sysdeps/linux/i386/sigaction.c | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) 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; }