From patchwork Fri Jan 12 09:26:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Cederman X-Patchwork-Id: 83973 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 213DE3857C41 for ; Fri, 12 Jan 2024 09:28:47 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) by sourceware.org (Postfix) with ESMTPS id 9E77C38582AD for ; Fri, 12 Jan 2024 09:26:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E77C38582AD Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=gaisler.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gaisler.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9E77C38582AD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705051612; cv=none; b=TzxUECqEKFyVRaVf1M3GeS1owtAgazUl7XRwr0PzHqVY/FlCU0CPG1G1QX5WiVymZqNTesSOAN90x/ZgX5QHxyNa6KU2qKY6OLZS02fCz4J5V36xErGnDR/zsvk4PH8zakg4TwSY2x/ek7soReeXiS2t+FB1AlxkWQtugNimxyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705051612; c=relaxed/simple; bh=fKEuUYrTvFYstRAWopubRrvARWKmY6mFaBzttqF7HWA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Vi4tKG75emIOEXo68MfYjTRvsvDc9ckGZYwMMNaztsoRvT2G/BoECg7n5uQJJ007prUxPt1vbw+fLVOvZtCo1Xxp4JppC8sO8V7aiE/H4TemcxOBZriGmYa0ManQsf8BeAOfSlofsYX8F8GMApKa6iY/V8KCwk0fFi8ydvQSHJw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4TBGPx2gxMz680c; Fri, 12 Jan 2024 10:26:45 +0100 (CET) Received: from cederman.got.gaisler.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4TBGPx0dPKz67yq; Fri, 12 Jan 2024 10:26:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=unoeuro; t=1705051605; bh=jXZLV/fMX0Xc5taLDg7vSO5KUtxHYsPv17lWT9S0zLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VI0UErHGyVhEkTyZVfm1g5rkLDHy2Vy3cdwrfQ/tGCr52BDZ0fMgZdRVRL/7PwACd pHEdqu/sfsj0ujeenv/emXnevXwqk9+ZewJ8gnkZmq1un7ZuJvPY8kFUY3ErQsSgsv z2Z4lak72Ft6+15h3fkY1q7cObWpsR1W561wrmRU= From: Daniel Cederman To: libc-alpha@sourceware.org Cc: daniel@gaisler.com, andreas@gaisler.com Subject: [PATCH] sparc: Remove unwind information from signal return stub functions Date: Fri, 12 Jan 2024 10:26:28 +0100 Message-Id: <20240112092628.2464455-6-cederman@gaisler.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240112092628.2464455-1-cederman@gaisler.com> References: <20240112092628.2464455-1-cederman@gaisler.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org The functions were previously written in C, but were not compiled with unwind information. The ENTRY/END macros includes .cfi_startproc and .cfi_endproc which adds unwind information. This caused the tests cleanup-8 and cleanup-10 in the GCC testsuite to fail. This patch adds a version of the ENTRY/END macros without the CFI instructions that can be used instead. sigaction registers a restorer address that is located two instructions before the stub function. This patch adds a two instruction padding to avoid that the unwinder accesses the unwind information from the function that the linker has placed right before it in memory. This fixes an issue with pthread_cancel that caused tst-mutex8-static (and other tests) to fail. This patch fixes the issues I have seen, but I am not sure if this is the right solution, so any feedback is welcome! Signed-off-by: Daniel Cederman --- sysdeps/sparc/sysdep.h | 9 +++++++++ .../unix/sysv/linux/sparc/sparc32/sigreturn_stub.S | 11 +++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sysdeps/sparc/sysdep.h b/sysdeps/sparc/sysdep.h index c00fe79fec..44a6952bff 100644 --- a/sysdeps/sparc/sysdep.h +++ b/sysdeps/sparc/sysdep.h @@ -76,6 +76,15 @@ C_LABEL(name) \ cfi_endproc; \ .size name, . - name +#define ENTRY_NOCFI(name) \ + .align 4; \ + .global C_SYMBOL_NAME(name); \ + .type name, @function; \ +C_LABEL(name) + +#define END_NOCFI(name) \ + .size name, . - name + #undef LOC #define LOC(name) .L##name diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sigreturn_stub.S b/sysdeps/unix/sysv/linux/sparc/sparc32/sigreturn_stub.S index 832223f8ce..21d36c50df 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/sigreturn_stub.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/sigreturn_stub.S @@ -23,12 +23,15 @@ [1] https://lkml.org/lkml/2016/5/27/465 */ -ENTRY (__rt_sigreturn_stub) + nop + nop + +ENTRY_NOCFI (__rt_sigreturn_stub) mov __NR_rt_sigreturn, %g1 ta 0x10 -END (__rt_sigreturn_stub) +END_NOCFI (__rt_sigreturn_stub) -ENTRY (__sigreturn_stub) +ENTRY_NOCFI (__sigreturn_stub) mov __NR_sigreturn, %g1 ta 0x10 -END (__sigreturn_stub) +END_NOCFI (__sigreturn_stub)