From patchwork Mon Jun 24 14:23:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92821 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 A375B386C5BC for ; Tue, 25 Jun 2024 08:31:02 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id C8570386C5B6 for ; Tue, 25 Jun 2024 08:28:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C8570386C5B6 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C8570386C5B6 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719304125; cv=none; b=SQbRD9BS4OvNHueND/RYtbXqoVYBNQFcpOnAPWTN/DxXsEEmjqTG9MwgM6F5dsJy61G4RUjjVy8I97IyGLUgB5ym/n3Hba/2Q8rKAWPA/mVXJg/nfeIOMIP30DUGzfFIcwnP4YIqi2pIoJVWLIfzGYdEHjeXka/x9MjyzIA+QVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719304125; c=relaxed/simple; bh=QRzDLZ5LACSNf4RX2rg5/Sfk+dJu2vRzCSdRNKrPbIc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=rngKUeZxJBCb0hoJEY1F2ZM3LCmdEad9KHzrXKcf8+svAmpfY513SdVV4oROq7Dbw4VAQTL7PyAU+d7v5YjK6bgeTXw3JLjmd3s5R0qA4CKOROleDhHvpJBSEwaPKp/zV9faNzOpvktmZwUR+yYbvzRJTbnTX8Qia+8vwYo6dbE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45OEHsGb023017; Mon, 24 Jun 2024 14:26:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=e80WBgoWBkgpR K32yMoTDlTlnFh+9Q3kHRKGG+s1VRo=; b=mhEkWNNRR3xF4Z89tCIVyarqGwTzI ZqRaRcWPav7jriYdMaHCC3AdJb7ltmY6oMXoglDochPA6V0VxCEGjC5BeIl0aJOa T8dM9axlrkJkOgrJoj3Xw2hhIr5lbI4xmdKxu4LQk9ay9Z7TgL5XZmtRSsWwZtUr XCsTBtTybBc2Rf7IDlOYRJbcNgJPJqK4ge4LIuY4WuC5x2pOvuR2PCk+9+NJAFNN Y2AFbC/yfdoiqvMAMQKHOWc0FGAYJfyUppG+Ln79wqM3bd65S8Lp6g0Mf9H01phr ehAc1nyGDPonrJQWnt9y/UINoTTdP5vLwwSiGq+uPK8B3jjX+F/5YsQow== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yyae880n9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:26:57 +0000 (GMT) Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45OEQuHV005374; Mon, 24 Jun 2024 14:26:56 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yyae880k1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:26:56 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45OD4TUS000616; Mon, 24 Jun 2024 14:23:43 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yxaems48c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:43 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENbGp50200918 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:39 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 62D4020040; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 389902004D; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel , Jan Beulich , Jan Hubicka , Andreas Jaeger , "H.J. Lu" Subject: [PATCH v4 01/15] x86: Remove unused SFrame CFI RA register variable Date: Mon, 24 Jun 2024 16:23:20 +0200 Message-Id: <20240624142334.3283823-2-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: C4IKjXm7Y3QymPsRqSAD6Hi-q3VGmq6B X-Proofpoint-GUID: fsZjnxWlkgJhDBsoG2oj3fbo5c_PHCvt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 phishscore=0 clxscore=1011 mlxscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org gas/ * config/tc-i386.c: Remove unused SFrame CFI RA register variable. Reviewed-by: Andreas Krebbel Reviewed-by: Indu Bhagat Acked-by: Jan Beulich Signed-off-by: Jens Remus --- Notes (jremus): Changes v2 -> v3: - Corrected formatting of ChangeLog in commit message. gas/config/tc-i386.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index e94b93701552..343848ad052d 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -639,7 +639,6 @@ static int shared = 0; unsigned int x86_sframe_cfa_sp_reg; /* The other CFA base register for SFrame stack trace info. */ unsigned int x86_sframe_cfa_fp_reg; -unsigned int x86_sframe_cfa_ra_reg; #endif From patchwork Mon Jun 24 14:23:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92788 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 58E62384601E for ; Mon, 24 Jun 2024 22:01:54 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id C76783846086 for ; Mon, 24 Jun 2024 22:01:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C76783846086 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C76783846086 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719266474; cv=none; b=xh1sml0gURQRJtVrTA1pav5BshxNh6uVIijAHJqaSlSFcmmoUP9sK0y+/UbYWNdauXg+JdLKPfO0CMeGH3xO3FxGbiii/or0EQYDbtny2EcWn26PvXhV/GIBDjAmS/D0LgkHzAog/g1TwnHQzh/c8IObbFCDN8qoLNI1tDUZXq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719266474; c=relaxed/simple; bh=kLzVInQOR/twZGKYC6ug+HTeuEdtITKE1dUdNYN9Yx0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=qivMWpcckL/PH7RWItdFKiCJCQpuTnYMVVfG9yNEJhWs8giEmsX/feqmOnr6aU5vFUq2bAFslD/AX7uCadeEuQPPDXScxCrbc1mobrOIxgkI+//ya/y0Lb3bf/SJZRBPRk8Fd46/6hmL2mQUzwx2ksf+dd1Y8nvy0sNLXe+H6bU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45ODdsW1000406; Mon, 24 Jun 2024 14:26:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=KM5HscyotSEOC 0JZg3vbCVhU1XVsChW/wVj5kT2hiS0=; b=oWzAty6+vbtYdR2Zd6OrU6kxr+Q3x MNUDItIhU7JjWzrvpqv569LyVvRfz3oIZfgq0C7vGrMV9o59fUtOlzfNhpjtC+x+ 8jnriiWs8z1DVQbfpH9QHFnUuR4TtpqSgKVeaTY4FbzzIYZTb4RZkGJwCU4ZkzHh fVGlU0M0FCg000rfydASa23W/pe8aB88Tr31Cqw37JdtRuRm+ep0By6b09w5DrFP w5bD02ZSbvV/OBk47XkUlDq6WC8nAvLKyhha0NaJs/StI2TFzqfB5mUOo5oHLvk8 GZBW3wSTtub52B00OICHy25Os2PjPakDV4N15SQWWS5CiyU+d2CJrbbjQ== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yy9n786b5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:26:24 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45OCTImW019602; Mon, 24 Jun 2024 14:23:43 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yx9xps8ba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:43 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENbh842205580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:39 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7E03D2004D; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 66EEA2004E; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 02/15] gas: Enhance arch-specific SFrame configuration descriptions Date: Mon, 24 Jun 2024 16:23:21 +0200 Message-Id: <20240624142334.3283823-3-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 0U2el7WeOOb3xPlXgXmh75-Vf4rss-Jo X-Proofpoint-ORIG-GUID: 0U2el7WeOOb3xPlXgXmh75-Vf4rss-Jo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 phishscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org Explicitly mention "SFrame" in the descriptions for the architecture- specific SFrame configuration macros, variables, and functions. Use the term "frame pointer" (FP) instead of "base pointer". This aligns with the terminology used in the SFrame specification. Additionally it helps not to confuse "base-pointer register" with the term "BASE_REG" used in the specification to denote either the SP or FP register. Specify what the SFRAME_CFA_*_REG register numbers are used for: - SP (stack pointer): CFA tracking - FP (frame pointer): CFA and FP tracking - RA (return address): RA tracking Align the descriptions for definitions in the source files to the declarations in the header files. gas/ * config/tc-aarch64.h: Enhance architecture-specific SFrame configuration descriptions. * config/tc-aarch64.c: Likewise. * config/tc-i386.h: Likewise. * config/tc-i386.c: Likewise. Signed-off-by: Jens Remus --- Notes (jremus): Changes v3 -> v4: - Removed dash in terms "stack pointer", "frame pointer", and "return address" as requested by Indu. Changes v2 -> v3: - Add "SFrame" to architecture-specific SFrame macro, variable, and function descriptions as suggested by Indu. Do so for all and not only those previously touched. - Reword further SFrame macro, variable, and function descriptions to align with those previously touched. - Align description of definition in source with declaration in header. - Corrected formatting of ChangeLog in commit message. - Changed commit subject prefix from "sframe" to "gas". gas/config/tc-aarch64.c | 6 +++--- gas/config/tc-aarch64.h | 12 ++++++------ gas/config/tc-i386.c | 5 +++++ gas/config/tc-i386.h | 10 +++++----- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 885ea65b8eb0..6ec883734375 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -8984,7 +8984,7 @@ aarch64_support_sframe_p (void) return (aarch64_abi == AARCH64_ABI_LP64); } -/* Specify if RA tracking is needed. */ +/* Whether SFrame return address tracking is needed. */ bool aarch64_sframe_ra_tracking_p (void) @@ -8992,8 +8992,8 @@ aarch64_sframe_ra_tracking_p (void) return true; } -/* Specify the fixed offset to recover RA from CFA. - (useful only when RA tracking is not needed). */ +/* The fixed offset from CFA for SFrame to recover the return address. + (useful only when SFrame RA tracking is not needed). */ offsetT aarch64_sframe_cfa_ra_offset (void) diff --git a/gas/config/tc-aarch64.h b/gas/config/tc-aarch64.h index 1b8badad9fdc..0063e85a7f13 100644 --- a/gas/config/tc-aarch64.h +++ b/gas/config/tc-aarch64.h @@ -267,24 +267,24 @@ extern void aarch64_after_parse_args (void); extern bool aarch64_support_sframe_p (void); #define support_sframe_p aarch64_support_sframe_p -/* The stack-pointer register number for SFrame stack trace info. */ +/* The stack pointer DWARF register number for SFrame CFA tracking. */ extern unsigned int aarch64_sframe_cfa_sp_reg; #define SFRAME_CFA_SP_REG aarch64_sframe_cfa_sp_reg -/* The base-pointer register number for CFA stack trace info. */ +/* The frame pointer DWARF register number for SFrame CFA and FP tracking. */ extern unsigned int aarch64_sframe_cfa_fp_reg; #define SFRAME_CFA_FP_REG aarch64_sframe_cfa_fp_reg -/* The return address register number for CFA stack trace info. */ +/* The return address DWARF register number for SFrame RA tracking. */ extern unsigned int aarch64_sframe_cfa_ra_reg; #define SFRAME_CFA_RA_REG aarch64_sframe_cfa_ra_reg -/* Specify if RA tracking is needed. */ +/* Whether SFrame return address tracking is needed. */ extern bool aarch64_sframe_ra_tracking_p (void); #define sframe_ra_tracking_p aarch64_sframe_ra_tracking_p -/* Specify the fixed offset to recover RA from CFA. - (useful only when RA tracking is not needed). */ +/* The fixed offset from CFA for SFrame to recover the return address. + (useful only when SFrame RA tracking is not needed). */ extern offsetT aarch64_sframe_cfa_ra_offset (void); #define sframe_cfa_ra_offset aarch64_sframe_cfa_ra_offset diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 343848ad052d..f2c354108ea5 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -11440,6 +11440,7 @@ x86_cleanup (void) subseg_set (seg, subseg); } +/* Whether SFrame stack trace info is supported. */ bool x86_support_sframe_p (void) { @@ -11447,6 +11448,7 @@ x86_support_sframe_p (void) return (x86_elf_abi == X86_64_ABI); } +/* Whether SFrame return address tracking is needed. */ bool x86_sframe_ra_tracking_p (void) { @@ -11456,6 +11458,8 @@ x86_sframe_ra_tracking_p (void) return false; } +/* The fixed offset from CFA for SFrame to recover the return address. + (useful only when SFrame RA tracking is not needed). */ offsetT x86_sframe_cfa_ra_offset (void) { @@ -11463,6 +11467,7 @@ x86_sframe_cfa_ra_offset (void) return (offsetT) -8; } +/* The abi/arch indentifier for SFrame. */ unsigned char x86_sframe_get_abi_arch (void) { diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index 7aae7a33dc14..8b0fc6398aac 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -441,20 +441,20 @@ extern bool x86_scfi_callee_saved_p (uint32_t dw2reg_num); extern bool x86_support_sframe_p (void); #define support_sframe_p x86_support_sframe_p -/* The stack-pointer register number for SFrame stack trace info. */ +/* The stack pointer DWARF register number for SFrame CFA tracking. */ extern unsigned int x86_sframe_cfa_sp_reg; #define SFRAME_CFA_SP_REG x86_sframe_cfa_sp_reg -/* The frame-pointer register number for SFrame stack trace info. */ +/* The frame pointer DWARF register number for SFrame CFA and FP tracking. */ extern unsigned int x86_sframe_cfa_fp_reg; #define SFRAME_CFA_FP_REG x86_sframe_cfa_fp_reg -/* Specify if RA tracking is needed. */ +/* Whether SFrame return address tracking is needed. */ extern bool x86_sframe_ra_tracking_p (void); #define sframe_ra_tracking_p x86_sframe_ra_tracking_p -/* Specify the fixed offset to recover RA from CFA. - (useful only when RA tracking is not needed). */ +/* The fixed offset from CFA for SFrame to recover the return address. + (useful only when SFrame RA tracking is not needed). */ extern offsetT x86_sframe_cfa_ra_offset (void); #define sframe_cfa_ra_offset x86_sframe_cfa_ra_offset From patchwork Mon Jun 24 14:23:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92789 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 1E24F386C58E for ; Mon, 24 Jun 2024 22:02:03 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 6B1E4384770C for ; Mon, 24 Jun 2024 22:01:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B1E4384770C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6B1E4384770C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719266490; cv=none; b=x89Hs08fvZjUmdCilIfUpC6uCj4Va6mAqjsLIE4gLuMFgO9lX/+GqZvlTUvSX0MhRzNcLceF7OtkpPK1g8MKAMDcJjv9szgAnvy/10uAz47Kk0PtiiYUerMBxx85SHsRJ7HROKlX6S/5zkq+88GyFM6gPwMZnNofWhdFlDshV/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719266490; c=relaxed/simple; bh=O0D8FVoSGvZINn8tXtpsuOD1MlAWczZ+5J2XcpkLe/0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=kn2q53u4i2XfdERvpjAdD5hx3vn6Z4TzhMYF+BfTQLrFpVVXy7CvLfKFGb/6IxQiSH7Qs+ctbUc2wnpFeS3pC9otSfKr6vEfIEg2geoGfCTCGOFp3e/vk5itwDfv+dPotQ33zxkrMFYbKcFTm/0bUlMRK3G5YG3eNZ10CY0PI5g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45ODwVSU015534; Mon, 24 Jun 2024 14:27:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=0JZGZ0hol+hUK A+qmR8bpOcSegDp9Ca9plqwrxKm7Ck=; b=dud0Q6HcHdC3nkqZhxjxt1v41IIuO Vj+k9Nkba5tEhbgEG7zvhHQ1NmlM7Q2z90iD6KFsRucXmpPEDsjWdkzrjWDRw9Ps zPOBP38VyPyB6tLtFuGgJO6tvm7zmPlAPV/RW0mVC5IpawWUl5HTJGx5SClI6sFT 0TNwu+9lOzzj/eVU4LD8ScxDZ9UwyrLdqPG9l1pmzLILocIYGGaEfRULMDHh55R/ Lyhmm90iyugXOq9ROHy2lphbBj8kNQ8oHJbqDbKoEB9Dhk7wK9aeH2lLDW+5WZMH P7AavswYPGsnqSapvn5gbYx1dEPSDc7Y3HUE6sgaTJ8gDM+rGuLKEPL5A== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yya59g2tg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:27:06 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45OEMopl032376; Mon, 24 Jun 2024 14:23:43 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yxbn30tkn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:43 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENbuO56951120 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:39 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A18F82004E; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82B572004F; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 03/15] readelf/objdump: Dump SFrame CFA fixed FP and RA offsets Date: Mon, 24 Jun 2024 16:23:22 +0200 Message-Id: <20240624142334.3283823-4-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: T_4czUN0Iamgt17Fi1PGGpYKIDCYs1wG X-Proofpoint-ORIG-GUID: T_4czUN0Iamgt17Fi1PGGpYKIDCYs1wG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=999 clxscore=1015 mlxscore=0 malwarescore=0 spamscore=0 suspectscore=0 bulkscore=0 impostorscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org The SFrame format allows architectures to specify fixed offsets from the CFA, if any, from which the frame pointer (FP) and/or return address (RA) may be recovered. These offsets are stored in the SFrame header. For instance the SFrame generation in the assembler for x86 AMD64 specifies a fixed offset from the CFA, from which the return address (RA) may be recovered. When dumping the SFrame header, for instance in readelf/objdump with option --sframe, do also dump the specified fixed offsets from the CFA, if any, from which the frame pointer (FP) and return address (RA) may be recovered. Update the common SFrame test case verification patterns to allow for the optional dumping of the CFA fixed FP/RA offsets. Update the x86- specific SFrame and SCFI test case verification patterns to require a CFA fixed RA offset of -8. libsframe/ * sframe-dump.c: Dump CFA fixed FP and RA offsets. gas/testsuite/ * gas/cfi-sframe/cfi-sframe-common-1.d: Test for optional fixed FP and RA offsets. * gas/cfi-sframe/cfi-sframe-common-2.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-3.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-4.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-5.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-6.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-7.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-8.d: Likewise. * gas/cfi-sframe/cfi-sframe-x86_64-1.d: Test for fixed RA offset. * gas/cfi-sframe/common-empty-1.d: Test for optional fixed FP and RA offsets. * gas/cfi-sframe/common-empty-2.d: Likewise. * gas/cfi-sframe/common-empty-3.d: Likewise. * gas/scfi/x86_64/scfi-cfi-sections-1.d: Test for SFrame fixed RA offset. * gas/scfi/x86_64/scfi-dyn-stack-1.d: Likewise. ld/testsuite/ * ld-x86-64/sframe-plt-1.d: Test for SFrame fixed RA offset. * ld-x86-64/sframe-simple-1.d: Likewise. Reviewed-by: Andreas Krebbel Reviewed-by: Indu Bhagat Signed-off-by: Jens Remus --- Notes (jremus): Changes v2 -> v3: - Updated gas synthesized CFI test cases for x86 AMD64 to test for architecture-specific fixed RA offset instead of using a pattern. - Updated ld SFrame test cases for x86 AMD64 to test for architecture- specific fixed RA offset. - Corrected formatting of ChangeLog in commit message. gas/testsuite/gas/cfi-sframe/cfi-sframe-common-1.d | 2 ++ gas/testsuite/gas/cfi-sframe/cfi-sframe-common-2.d | 2 ++ gas/testsuite/gas/cfi-sframe/cfi-sframe-common-3.d | 2 ++ gas/testsuite/gas/cfi-sframe/cfi-sframe-common-4.d | 2 ++ gas/testsuite/gas/cfi-sframe/cfi-sframe-common-5.d | 2 ++ gas/testsuite/gas/cfi-sframe/cfi-sframe-common-6.d | 2 ++ gas/testsuite/gas/cfi-sframe/cfi-sframe-common-7.d | 2 ++ gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.d | 2 ++ gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-1.d | 1 + gas/testsuite/gas/cfi-sframe/common-empty-1.d | 2 ++ gas/testsuite/gas/cfi-sframe/common-empty-2.d | 2 ++ gas/testsuite/gas/cfi-sframe/common-empty-3.d | 2 ++ gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d | 1 + gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d | 1 + ld/testsuite/ld-x86-64/sframe-plt-1.d | 1 + ld/testsuite/ld-x86-64/sframe-simple-1.d | 1 + libsframe/sframe-dump.c | 10 ++++++++++ 17 files changed, 37 insertions(+) diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-1.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-1.d index 32577f31860e..5f4ae00747de 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-1.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-1.d @@ -8,6 +8,8 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE +#? CFA fixed FP offset: \-?\d+ +#? CFA fixed RA offset: \-?\d+ Num FDEs: 1 Num FREs: 1 diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-2.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-2.d index 3e3f74dbe424..ded8c450a942 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-2.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-2.d @@ -8,6 +8,8 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE +#? CFA fixed FP offset: \-?\d+ +#? CFA fixed RA offset: \-?\d+ Num FDEs: 1 Num FREs: 1 diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-3.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-3.d index 6430d463a891..d23fd9790f63 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-3.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-3.d @@ -8,6 +8,8 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE +#? CFA fixed FP offset: \-?\d+ +#? CFA fixed RA offset: \-?\d+ Num FDEs: 1 Num FREs: 1 diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-4.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-4.d index 319ff96cce2a..ca559bd0a029 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-4.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-4.d @@ -8,6 +8,8 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE +#? CFA fixed FP offset: \-?\d+ +#? CFA fixed RA offset: \-?\d+ Num FDEs: 1 Num FREs: 3 diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-5.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-5.d index 82d34973ddde..ee82053e13db 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-5.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-5.d @@ -8,6 +8,8 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE +#? CFA fixed FP offset: \-?\d+ +#? CFA fixed RA offset: \-?\d+ Num FDEs: 1 Num FREs: 3 diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-6.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-6.d index fe6917c70800..9d54b98552bf 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-6.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-6.d @@ -8,6 +8,8 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE +#? CFA fixed FP offset: \-?\d+ +#? CFA fixed RA offset: \-?\d+ Num FDEs: 1 Num FREs: 3 diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-7.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-7.d index 39724d9cdf19..2b7fe3aec8f4 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-7.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-7.d @@ -8,6 +8,8 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE +#? CFA fixed FP offset: \-?\d+ +#? CFA fixed RA offset: \-?\d+ Num FDEs: 1 Num FREs: 3 diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.d index c0a0e627fad9..d654e1d0bcd4 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.d @@ -8,6 +8,8 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE +#? CFA fixed FP offset: \-?\d+ +#? CFA fixed RA offset: \-?\d+ Num FDEs: 1 Num FREs: 2 diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-1.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-1.d index ae36c21b3b7c..c8b5e6adfea0 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-1.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-1.d @@ -8,6 +8,7 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE + CFA fixed RA offset: \-8 Num FDEs: 1 Num FREs: 4 diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-1.d b/gas/testsuite/gas/cfi-sframe/common-empty-1.d index b133b15b051d..125612ff841f 100644 --- a/gas/testsuite/gas/cfi-sframe/common-empty-1.d +++ b/gas/testsuite/gas/cfi-sframe/common-empty-1.d @@ -9,6 +9,8 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE +#? CFA fixed FP offset: \-?\d+ +#? CFA fixed RA offset: \-?\d+ Num FDEs: 0 Num FREs: 0 diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-2.d b/gas/testsuite/gas/cfi-sframe/common-empty-2.d index c5bc8594f1b7..59328fc1033f 100644 --- a/gas/testsuite/gas/cfi-sframe/common-empty-2.d +++ b/gas/testsuite/gas/cfi-sframe/common-empty-2.d @@ -9,6 +9,8 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE +#? CFA fixed FP offset: \-?\d+ +#? CFA fixed RA offset: \-?\d+ Num FDEs: 0 Num FREs: 0 diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-3.d b/gas/testsuite/gas/cfi-sframe/common-empty-3.d index df0b19ee1bd1..5914c620760d 100644 --- a/gas/testsuite/gas/cfi-sframe/common-empty-3.d +++ b/gas/testsuite/gas/cfi-sframe/common-empty-3.d @@ -8,6 +8,8 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE +#? CFA fixed FP offset: \-?\d+ +#? CFA fixed RA offset: \-?\d+ Num FDEs: 0 Num FREs: 0 diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d index 5962980256c1..c45933b72edc 100644 --- a/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d +++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d @@ -8,6 +8,7 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE + CFA fixed RA offset: \-8 Num FDEs: 1 Num FREs: 5 diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d index b51546af1494..6cd0484d5793 100644 --- a/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d +++ b/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d @@ -9,6 +9,7 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: NONE + CFA fixed RA offset: \-8 Num FDEs: 1 Num FREs: 4 diff --git a/ld/testsuite/ld-x86-64/sframe-plt-1.d b/ld/testsuite/ld-x86-64/sframe-plt-1.d index ca82cf20ca91..6aea5f424690 100644 --- a/ld/testsuite/ld-x86-64/sframe-plt-1.d +++ b/ld/testsuite/ld-x86-64/sframe-plt-1.d @@ -12,6 +12,7 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: SFRAME_F_FDE_SORTED + CFA fixed RA offset: \-8 #... Function Index : diff --git a/ld/testsuite/ld-x86-64/sframe-simple-1.d b/ld/testsuite/ld-x86-64/sframe-simple-1.d index adc4b7419307..5ffd0ca78187 100644 --- a/ld/testsuite/ld-x86-64/sframe-simple-1.d +++ b/ld/testsuite/ld-x86-64/sframe-simple-1.d @@ -12,6 +12,7 @@ Contents of the SFrame section .sframe: Version: SFRAME_VERSION_2 Flags: SFRAME_F_FDE_SORTED + CFA fixed RA offset: \-8 #... Function Index : diff --git a/libsframe/sframe-dump.c b/libsframe/sframe-dump.c index 42a086a5691f..493d052ce91f 100644 --- a/libsframe/sframe-dump.c +++ b/libsframe/sframe-dump.c @@ -47,6 +47,8 @@ dump_sframe_header (sframe_decoder_ctx *sfd_ctx) uint8_t flags; char *flags_str; const char *ver_str = NULL; + int8_t cfa_fixed_fp_offset; + int8_t cfa_fixed_ra_offset; const sframe_header *header = &(sfd_ctx->sfd_header); /* Prepare SFrame section version string. */ @@ -82,12 +84,20 @@ dump_sframe_header (sframe_decoder_ctx *sfd_ctx) else strcpy (flags_str, "NONE"); + /* CFA fixed FP and RA offsets. */ + cfa_fixed_fp_offset = header->sfh_cfa_fixed_fp_offset; + cfa_fixed_ra_offset = header->sfh_cfa_fixed_ra_offset; + const char* subsec_name = "Header"; printf ("\n"); printf (" %s :\n", subsec_name); printf ("\n"); printf (" Version: %s\n", ver_str); printf (" Flags: %s\n", flags_str); + if (cfa_fixed_fp_offset != SFRAME_CFA_FIXED_FP_INVALID) + printf (" CFA fixed FP offset: %d\n", cfa_fixed_fp_offset); + if (cfa_fixed_ra_offset != SFRAME_CFA_FIXED_RA_INVALID) + printf (" CFA fixed RA offset: %d\n", cfa_fixed_ra_offset); printf (" Num FDEs: %d\n", sframe_decoder_get_num_fidx (sfd_ctx)); printf (" Num FREs: %d\n", header->sfh_num_fres); From patchwork Mon Jun 24 14:23:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92766 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 5CA5F384AB72 for ; Mon, 24 Jun 2024 15:54:12 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 427FE3858D35 for ; Mon, 24 Jun 2024 15:53:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 427FE3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 427FE3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719244414; cv=none; b=FnW9k4TJeDdChGXbgYWtXGdYPttxJyFbJ1ot0AxSBQg1ebcBZmy83NSg9K3UxZyaBwwqnOFa73eCgrLXA32wHujNQ/KGCoJ7C+Eu34H5hOqPF0q4cMmcDChpnXQbyrRvaVi5llgYxHkMLamOm/hJNaFjlaXP0/ygCKwRN6vkcyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719244414; c=relaxed/simple; bh=Y+gObiHGU7YaPNq65sx4E33jGGMo4F2e9CL68uY29IA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Px7zTkKd/aQ/IPu/rREjd5CKcEyak9EDBF5s3BIDytfi1OlCdVVwXETmsYq+ZQ7cVWwI3l+HY0k0TNb2DioMtFZFC5p0drtxd+O37g4/BjHt71KOoZ5OLQf8/evjwPWPRUHZnZ2BqLxtqz1ezPUprqAwjS8lHw9m/znrFI71+3o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45OEKdnN016660; Mon, 24 Jun 2024 14:26:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=98saF3TDj+z3C adw4EvZeBKqv260nmkvr8rCu0+21bU=; b=mUzLF4bVWWfX7rvJoAhHs5cvGYIRX k7lxCyni/9Gio0T1BleqaDciIsUpFjzysiV07/a/pHM7wBn8hXQrhBZZxMna1xe+ YVF/ioKT2zMJIZOCBzJ9QTTaqxoVyXgwxJQFWU2WVkSzgonX0jjEna3P/un1P5fp IyfzliwNzD3j0VB+5P9rP7bs26+S1NeMGHOq3OkvD0jvLBnpDJvd0I4h/qlB+qZB 6kdxa0uXXyDVClaR08b0wkgByxjjQz6mJbQ2INGgW6W63mMLZOamw3knGC97GCf3 H5ttYDc/WITBxo4gM1CDwANC3ZCIPOYSCtfsZjN1uATHNmZUwNBBWk5bQ== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yy9n786b3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:26:21 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45ODiWwc019984; Mon, 24 Jun 2024 14:23:43 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yxb5m8xs7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:43 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENbp652953460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:39 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C50E22004F; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A628520043; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 04/15] readelf/objdump: Display SFrame fixed RA offset as 'f' in dump Date: Mon, 24 Jun 2024 16:23:23 +0200 Message-Id: <20240624142334.3283823-5-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: _LfJESATUfbguy3yOSKYGyD-UsyXex6j X-Proofpoint-ORIG-GUID: _LfJESATUfbguy3yOSKYGyD-UsyXex6j X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 phishscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org For the SFrame FRE frame-pointer (FP) offset from CFA a 'u' is displayed if it is unavailable. For the SFrame FRE return-address (RA) offset from CFA a 'u' was displayed if the ABI uses a fixed RA offset from CFA. By chance a 'u' was also displayed if the RA offset is unavailable, as the string buffer was not initialized after formatting the FP offset. Note that it could not occur that the FP offset was erroneously displayed as RA offset, as the SFrame format cannot have a FRE with FP offset without RA offset. For the FRE RA offset display 'f' if the ABI uses a fixed RA offset from CFA. Display a 'u' if it is unavailable. libsframe/ * sframe-dump.c: Display SFrame fixed RA offset as 'f' in dump. gas/testsuite/ * gas/cfi-sframe/cfi-sframe-common-4.d: Test for RA displayed either as 'u' (if RA tracking) or as 'f' (fixed RA offset if no RA tracking). * gas/cfi-sframe/cfi-sframe-common-5.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-6.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-7.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-8.d: Likewise. * gas/cfi-sframe/cfi-sframe-x86_64-1.d: Test for RA displayed as 'f' (fixed RA offset), as x86-64 does not use RA tracking. * gas/scfi/x86_64/scfi-cfi-sections-1.d: Likewise. * gas/scfi/x86_64/scfi-dyn-stack-1.d: Likewise. ld/testsuite/ * ld-x86-64/sframe-plt-1.d: Test for RA displayed as 'f' (fixed RA offset), as x86-64 does not use RA tracking. * ld-x86-64/sframe-simple-1.d: Likewise. Reviewed-by: Indu Bhagat Signed-off-by: Jens Remus --- Notes (jremus): Changes v2 -> v3: - New patch. If the change in display of fixed RA offset as 'f' is undesired the patch can be reduced to fixing the logic to display the FP offset. .../gas/cfi-sframe/cfi-sframe-common-4.d | 4 ++-- .../gas/cfi-sframe/cfi-sframe-common-5.d | 4 ++-- .../gas/cfi-sframe/cfi-sframe-common-6.d | 4 ++-- .../gas/cfi-sframe/cfi-sframe-common-7.d | 4 ++-- .../gas/cfi-sframe/cfi-sframe-common-8.d | 2 +- .../gas/cfi-sframe/cfi-sframe-x86_64-1.d | 8 ++++---- .../gas/scfi/x86_64/scfi-cfi-sections-1.d | 10 +++++----- gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d | 10 +++++----- ld/testsuite/ld-x86-64/sframe-plt-1.d | 8 ++++---- ld/testsuite/ld-x86-64/sframe-simple-1.d | 16 ++++++++-------- libsframe/sframe-dump.c | 8 +++++--- 11 files changed, 40 insertions(+), 38 deletions(-) diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-4.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-4.d index ca559bd0a029..8632613f532f 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-4.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-4.d @@ -17,7 +17,7 @@ Contents of the SFrame section .sframe: func idx \[0\]: pc = 0x0, size = 12 bytes STARTPC + CFA + FP + RA + #... - 0+0004 +sp\+16 +u +u + - 0+0008 +sp\+32 +u +u + + 0+0004 +sp\+16 +u +[uf] + + 0+0008 +sp\+32 +u +[uf] + #pass diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-5.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-5.d index ee82053e13db..dd2c32d3d9fc 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-5.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-5.d @@ -17,7 +17,7 @@ Contents of the SFrame section .sframe: func idx \[0\]: pc = 0x0, size = 12 bytes STARTPC + CFA + FP + RA + #... - 0+0004 +sp\+16 +u +u + - 0+0008 +sp\+24 +u +u + + 0+0004 +sp\+16 +u +[uf] + + 0+0008 +sp\+24 +u +[uf] + #pass diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-6.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-6.d index 9d54b98552bf..34390c46a074 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-6.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-6.d @@ -17,7 +17,7 @@ Contents of the SFrame section .sframe: func idx \[0\]: pc = 0x0, size = 12 bytes STARTPC + CFA + FP + RA + #... - 0+0004 +sp\+8 +u +u + - 0+0008 +sp\+8 +u +u + + 0+0004 +sp\+8 +u +[uf] + + 0+0008 +sp\+8 +u +[uf] + #pass diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-7.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-7.d index 2b7fe3aec8f4..61efb9c4ed12 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-7.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-7.d @@ -17,7 +17,7 @@ Contents of the SFrame section .sframe: func idx \[0\]: pc = 0x0, size = 12 bytes STARTPC + CFA + FP + RA + #... - 0+0004 +sp\+8 +u +u + - 0+0008 +sp\+8 +u +u + + 0+0004 +sp\+8 +u +[uf] + + 0+0008 +sp\+8 +u +[uf] + #pass diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.d index d654e1d0bcd4..d77645636b36 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.d @@ -17,6 +17,6 @@ Contents of the SFrame section .sframe: func idx \[0\]: pc = 0x0, size = 8 bytes STARTPC + CFA + FP + RA + #... - 0+0004 +sp\+16 +u +u + + 0+0004 +sp\+16 +u +[uf] + #pass diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-1.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-1.d index c8b5e6adfea0..88b4cc63dbaa 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-1.d +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-1.d @@ -16,8 +16,8 @@ Contents of the SFrame section .sframe: func idx \[0\]: pc = 0x0, size = 25 bytes STARTPC +CFA +FP +RA + - 0+0000 +sp\+8 +u +u + - 0+0001 +sp\+16 +c\-16 +u + - 0+0004 +fp\+16 +c\-16 +u + - 0+0018 +sp\+8 +c\-16 +u + + 0+0000 +sp\+8 +u +f + + 0+0001 +sp\+16 +c\-16 +f + + 0+0004 +fp\+16 +c\-16 +f + + 0+0018 +sp\+8 +c\-16 +f + #pass diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d index c45933b72edc..7c247e33a6e8 100644 --- a/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d +++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d @@ -16,10 +16,10 @@ Contents of the SFrame section .sframe: func idx \[0\]: pc = 0x0, size = 12 bytes STARTPC + CFA + FP + RA + - 0+0000 +sp\+8 +u +u + - 0+0001 +sp\+16 +c\-16 +u + - 0+0004 +fp\+16 +c-16 +u + - 0+000a +sp\+16 +c\-16 +u + - 0+000b +sp\+8 +u +u + + 0+0000 +sp\+8 +u +f + + 0+0001 +sp\+16 +c\-16 +f + + 0+0004 +fp\+16 +c-16 +f + + 0+000a +sp\+16 +c\-16 +f + + 0+000b +sp\+8 +u +f + #pass diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d index 6cd0484d5793..c6a9b53f4e09 100644 --- a/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d +++ b/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d @@ -16,10 +16,10 @@ Contents of the SFrame section .sframe: Function Index : func idx \[0\]: pc = 0x0, size = 87 bytes - STARTPC + CFA + FP + RA - 0+0000 + sp\+8 + u + u - 0+0001 + sp\+16 + c-16 + u - 0+0004 + fp\+16 + c-16 + u - 0+0056 + sp\+8 + u + u + STARTPC + CFA + FP + RA + + 0+0000 + sp\+8 + u + f + + 0+0001 + sp\+16 + c-16 + f + + 0+0004 + fp\+16 + c-16 + f + + 0+0056 + sp\+8 + u + f + #pass diff --git a/ld/testsuite/ld-x86-64/sframe-plt-1.d b/ld/testsuite/ld-x86-64/sframe-plt-1.d index 6aea5f424690..52bca18d4c08 100644 --- a/ld/testsuite/ld-x86-64/sframe-plt-1.d +++ b/ld/testsuite/ld-x86-64/sframe-plt-1.d @@ -19,12 +19,12 @@ Contents of the SFrame section .sframe: func idx \[0\]: pc = 0x1000, size = 16 bytes STARTPC +CFA +FP +RA + - 0+1000 +sp\+16 +u +u + - 0+1006 +sp\+24 +u +u + + 0+1000 +sp\+16 +u +f + + 0+1006 +sp\+24 +u +f + func idx \[1\]: pc = 0x1010, size = 16 bytes STARTPC\[m\] +CFA +FP +RA + - 0+0000 +sp\+8 +u +u + - 0+000b +sp\+16 +u +u + + 0+0000 +sp\+8 +u +f + + 0+000b +sp\+16 +u +f + #... diff --git a/ld/testsuite/ld-x86-64/sframe-simple-1.d b/ld/testsuite/ld-x86-64/sframe-simple-1.d index 5ffd0ca78187..7d88419226f1 100644 --- a/ld/testsuite/ld-x86-64/sframe-simple-1.d +++ b/ld/testsuite/ld-x86-64/sframe-simple-1.d @@ -23,14 +23,14 @@ Contents of the SFrame section .sframe: func idx \[2\]: pc = 0x1020, size = 53 bytes STARTPC +CFA +FP +RA + - 0+1020 +sp\+8 +u +u + - 0+1021 +sp\+16 +c-16 +u + - 0+1024 +fp\+16 +c-16 +u + - 0+1054 +sp\+8 +c-16 +u + + 0+1020 +sp\+8 +u +f + + 0+1021 +sp\+16 +c-16 +f + + 0+1024 +fp\+16 +c-16 +f + + 0+1054 +sp\+8 +c-16 +f + func idx \[3\]: pc = 0x1055, size = 37 bytes STARTPC +CFA +FP +RA + - 0+1055 +sp\+8 +u +u + - 0+1056 +sp\+16 +c-16 +u + - 0+1059 +fp\+16 +c-16 +u + - 0+1079 +sp\+8 +c-16 +u + + 0+1055 +sp\+8 +u +f + + 0+1056 +sp\+16 +c-16 +f + + 0+1059 +fp\+16 +c-16 +f + + 0+1079 +sp\+8 +c-16 +f + diff --git a/libsframe/sframe-dump.c b/libsframe/sframe-dump.c index 493d052ce91f..69633d53a33a 100644 --- a/libsframe/sframe-dump.c +++ b/libsframe/sframe-dump.c @@ -181,13 +181,15 @@ dump_sframe_func_with_fres (sframe_decoder_ctx *sfd_ctx, printf ("%-10s", temp); /* Dump RA info. - If an ABI does not track RA offset, e.g., AMD64, display a 'u', + If an ABI does not track RA offset, e.g., AMD64, display 'f', else display the offset d as 'c+-d'. */ - if (sframe_decoder_get_fixed_ra_offset(sfd_ctx) + if (sframe_decoder_get_fixed_ra_offset (sfd_ctx) != SFRAME_CFA_FIXED_RA_INVALID) - strcpy (temp, "u"); + strcpy (temp, "f"); else if (err[2] == 0) sprintf (temp, "c%+d", ra_offset); + else + strcpy (temp, "u"); /* Mark SFrame FRE's RA information with "[s]" if the RA is mangled with signature bits. */ From patchwork Mon Jun 24 14:23:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92787 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 12F753846425 for ; Mon, 24 Jun 2024 22:01:00 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 339153858D35 for ; Mon, 24 Jun 2024 22:00:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 339153858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 339153858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719266431; cv=none; b=DnKb236DJFrmjI1NnGAImAF8FENTOf8njRF5ri7fD19pwxyeepJ0VCJ1hXqq7qes0rCL908TQXN2kcamfmbSBesZNfcEtI6+YtWJWmwEA4NJL+bl/fo7ktpEFwm2Q6AGyBNHK9Tqe+VNPv1FZyqhNi+G46eFyZd1hctVKvimJP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719266431; c=relaxed/simple; bh=sBzUTfO/7hvSOdjTJxIGmAdVB2oqd3YosvBZY+WsRPk=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=KiObKzZ4X4LCv7puR8HnWaszEeaWMmZaPEqQM8JFo0o1SuAmkX2buqVxYWYwYf5VOqU7lZdP3gmLBjZeQ4ZxUREsLtWp2Kn0LzNUD9kUExVx0tXI0Z/m5yNCnZhn3mBv626KuFLDXnmJbYAMADbo4azcyD4CqRFQiQn280WPJlE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45ODwpQG007885; Mon, 24 Jun 2024 14:23:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=UwFfUJVcgXm64 c7HRn1szVWuq2cTukekvgCysi7X7LE=; b=PfIBpACy/8gIyJ5kGtu2Wh2bmPD72 78agPwymy+JHqLYkDBnQSnXFV4P961s1cJpuXb0TpLyTmEl0zKH9PfUU0ctu3TWF d+VKEaYMTNKbJeqLLq0n9TRbH+QMfndz5XQM+GhmhBbtV7OaCms/ry7x19y2kwRy vlIswGdd4mA2Ehh0Dg0CWntrHQQl9jdmhyzxJ5kbVrtJDD5miAJKdpoG/Q9qC2YK u3h6TASnyA8SisHNadg6diDnQdOHPneUTTQANC0k9b+z1tgqAunRdSAJDKb+CGQo FDZz/AXqfsr3acaRmb2lrL7UBm0JlZuxZPlCrb3zPEp8Zm0cioPYWlf7g== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yya5a82yb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:44 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45ODgqSQ019800; Mon, 24 Jun 2024 14:23:43 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yxb5m8xs8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:43 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENcnN49086942 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:40 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E311620043; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C986720063; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 05/15] gas: Print DWARF call frame insn name in SFrame warning message Date: Mon, 24 Jun 2024 16:23:24 +0200 Message-Id: <20240624142334.3283823-6-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: AWpdwzeIYbJs-Qc3s-Z8pD9EcsbpQQs9 X-Proofpoint-GUID: AWpdwzeIYbJs-Qc3s-Z8pD9EcsbpQQs9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=999 phishscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org SFrame generation prints the DWARF call frame instruction opcode in hexadecimal. Leverage get_DW_CFA_name to additionally print the DWARF call frame instruction name in human readable form, while also respecting fake CFI types. Use "(unknown)", if the DWARF call frame instruction name is not known. While at it use the terminology "instruction" for these DW_CFA_*, as suggested by Indu. This changes the following assembler SFrame generation warning message as follows: Old: Warning: skipping SFrame FDE due to DWARF CFI op 0x New: Warning: skipping SFrame FDE; CFI insn (0x) gas/ * gen-sframe.c (sframe_get_cfi_name): New function to get the DWARF call frame instruction name for a DWARF call frame instruction opcode. (sframe_do_cfi_insn): Use sframe_get_cfi_name to print the DWARF call frame instruction name for the DWARF call frame instruction opcode in the warning message. gas/testsuite/ * gas/cfi-sframe/common-empty-1.d: Update expected SFrame warning message text for DWARF call frame insn name. * gas/cfi-sframe/common-empty-2.d: Likewise. Reviewed-by: Andreas Krebbel Reviewed-by: Indu Bhagat Signed-off-by: Jens Remus --- Notes (jremus): Changes v3 -> v4: - Change warning message text to "due to CFI insn", as suggested by Indu, to use proper DWARF terminology "CFI instruction" and shorten message text. Changes v2 -> v3: - Removed stale ChangeLog entries from commit message. - Corrected formatting of ChangeLog in commit message. gas/gen-sframe.c | 49 ++++++++++++++++++- gas/testsuite/gas/cfi-sframe/common-empty-1.d | 2 +- gas/testsuite/gas/cfi-sframe/common-empty-2.d | 2 +- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 238b76f88ed0..116d1f48f781 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1199,6 +1199,46 @@ sframe_xlate_do_gnu_window_save (struct sframe_xlate_ctx *xlate_ctx, return SFRAME_XLATE_OK; } +/* Returns the DWARF call frame instruction name or fake CFI name for the + specified CFI opcode, or NULL if the value is not recognized. */ + +static const char * +sframe_get_cfi_name (int cfi_opc) +{ + const char *cfi_name; + + switch (cfi_opc) + { + /* Fake CFI type; outside the byte range of any real CFI insn. */ + /* See gas/dw2gencfi.h. */ + case CFI_adjust_cfa_offset: + cfi_name = "CFI_adjust_cfa_offset"; + break; + case CFI_return_column: + cfi_name = "CFI_return_column"; + break; + case CFI_rel_offset: + cfi_name = "CFI_rel_offset"; + break; + case CFI_escape: + cfi_name = "CFI_escape"; + break; + case CFI_signal_frame: + cfi_name = "CFI_signal_frame"; + break; + case CFI_val_encoded_addr: + cfi_name = "CFI_val_encoded_addr"; + break; + case CFI_label: + cfi_name = "CFI_label"; + break; + default: + cfi_name = get_DW_CFA_name (cfi_opc); + } + + return cfi_name; +} + /* Process CFI_INSN and update the translation context with the FRE information. @@ -1274,7 +1314,14 @@ sframe_do_cfi_insn (struct sframe_xlate_ctx *xlate_ctx, /* An error here will cause no SFrame FDE later. Warn the user because this will affect the overall coverage and hence, asynchronicity. */ if (err) - as_warn (_("skipping SFrame FDE due to DWARF CFI op %#x"), op); + { + const char *cfi_name = sframe_get_cfi_name (op); + + if (!cfi_name) + cfi_name = _("(unknown)"); + as_warn (_("skipping SFrame FDE; CFI insn %s (%#x)"), + cfi_name, op); + } return err; } diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-1.d b/gas/testsuite/gas/cfi-sframe/common-empty-1.d index 125612ff841f..dbb48949c713 100644 --- a/gas/testsuite/gas/cfi-sframe/common-empty-1.d +++ b/gas/testsuite/gas/cfi-sframe/common-empty-1.d @@ -1,5 +1,5 @@ #as: --gsframe -#warning: skipping SFrame FDE due to DWARF CFI op 0xa +#warning: skipping SFrame FDE; CFI insn DW_CFA_remember_state \(0xa\) #objdump: --sframe=.sframe #name: Uninteresting cfi directives generate an empty SFrame section #... diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-2.d b/gas/testsuite/gas/cfi-sframe/common-empty-2.d index 59328fc1033f..7b2ce3e8c796 100644 --- a/gas/testsuite/gas/cfi-sframe/common-empty-2.d +++ b/gas/testsuite/gas/cfi-sframe/common-empty-2.d @@ -1,5 +1,5 @@ #as: --gsframe -#warning: skipping SFrame FDE due to DWARF CFI op 0xe +#warning: skipping SFrame FDE; CFI insn DW_CFA_def_cfa_offset \(0xe\) #objdump: --sframe=.sframe #name: SFrame supports only FP/SP based CFA #... From patchwork Mon Jun 24 14:23:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92828 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 028AD3843892 for ; Tue, 25 Jun 2024 10:51:35 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 23324386D61D for ; Tue, 25 Jun 2024 10:51:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23324386D61D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 23324386D61D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719312663; cv=none; b=RiRfKNFuy0vlMcgVJBsUklU0ARWEPnoTo9HobUchNQsgKTT9+GpHnjNuBrMpDbyezXkJPLRE9zpv21BiVgx+Sf7ZCzFkvvvbKIapIOyTiuHOTd58Og/1mNExJr8XY530VowZx9TBKz6O2KY3QPWNc8BHkTLBcXO82z7Md+VyhJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719312663; c=relaxed/simple; bh=5+tVaB4Vs742m/LoYmtpgM9BKyKsDycC/iUGrddmBGo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=qNP1KVGVpYRB7NRb7esqC7KwKvkxGZ0JMZrELCs72Dh4OAaDgEUjjsjUOo7wPbcXHsXj82jdSx/KpIE1P1GLH1ViA+tHrqakqbwq0UsPln4peHjWuDsXFv6d0xv8+DOhe6UFOWtX7AzbcuVcmR+52ODuq9XqFjxcO9y7kDslxso= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45OETcME021954; Mon, 24 Jun 2024 14:49:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=cLo0ptnAv3Idk R7tLojJIJ8eTx9IMQw4ICZiHXppdHY=; b=Uxx2+eTOLWP9po4yhcp+bliLNutDt jzJErqoSVSLMU65pyleTsolCvcvZQA9ooNLlGnM9CrW6gISt+Cul17H4kw+40Yu9 gG3KCs4sYDWCeHIRpDCgOIKBOlsIccB+6JbKr50h8I0fl1IxrsTgE3mRsinUivJQ Z5fck/hGumhD3khyXEw9B9Ocry87oxlaclts2sxNf/Ekt5BHZ0EnZEwEs0EBcogt zjQoTpWxiEl/JMvGc+08tGqsOTNeHpTVn7oeuNr91U88BWV6EJXGrHzesK/b6Zik Fe3L+/7rkQWzD8St5U5rAUlwD3+hIUqLfzkhlTsq7m3czkYqqH1J1eWgA== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yyakug1xp-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:49:42 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45ODt6KO019897; Mon, 24 Jun 2024 14:23:43 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yxb5m8xs9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:43 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENcmi56099090 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:40 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B3F82006A; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E5B1D20067; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 06/15] gas: Skip SFrame FDE if CFI specifies non-FP/SP base register Date: Mon, 24 Jun 2024 16:23:25 +0200 Message-Id: <20240624142334.3283823-7-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: zihIrjdCWxchgfhzkO8B4B5NJ017Kwbi X-Proofpoint-ORIG-GUID: zihIrjdCWxchgfhzkO8B4B5NJ017Kwbi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org Do not generate SFrame FDE if DWARF CFI directives .cfi_def_cfa or .cfi_def_cfa_register specify a CFA base register number other than the architecture-specific stack-pointer (SP) or frame-pointer (FP) register numbers. This also causes the assembler to print a warning message, so that skipping of the SFrame FDE does not occur silently. Update the generic ld SFrame test case to be architecture independent. Do not use CFI directive .cfi_def_cfa, as the specified CFA base register number is not a valid SP/FP register number on all architectures. An invalid SP/FP register number will now cause the assembler to print a warning message and skip SFrame FDE generation. Remove the offending CFI directive, that cannot be coded architecture- independent, as the test case requires SFrame information to be generated. This was reported by the Linaro-TCWG-CI for AArch64. gas/ * gen-sframe.c: Skip SFrame generation if CFI specifies non-FP/SP base register. ld/testsuite/ * ld-sframe/discard.s: Update generic SFrame test case to be architecture independent. Reviewed-by: Andreas Krebbel Reviewed-by: Indu Bhagat Signed-off-by: Jens Remus --- Notes (jremus): Changes v2 -> v3: - Corrected formatting of ChangeLog in commit message. Changes v1 -> v2: - Update generic SFrame test case to be architecture independent to resolve generic ld SFrame test case failure reported by Linaro-TCWG-CI for AArch64. It would fail similar on s390x. Without this patch the assembler would erroneously generate bad SFrame information for the s390-specific SFrame error test cases 1 and 2, that get introduced by patch "s390: Initial support to generate .sframe from CFI directives in assembler". gas/gen-sframe.c | 13 +++++++++++-- ld/testsuite/ld-sframe/discard.s | 1 - 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 116d1f48f781..52c2f3f4ff89 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -988,7 +988,11 @@ sframe_xlate_do_def_cfa (struct sframe_xlate_ctx *xlate_ctx, get_dw_fde_start_addrS (xlate_ctx->dw_fde)); } /* Define the current CFA rule to use the provided register and - offset. */ + offset. However, if the register is not FP/SP, skip creating + SFrame stack trace info for the function. */ + if (cfi_insn->u.r != SFRAME_CFA_SP_REG + && cfi_insn->u.r != SFRAME_CFA_FP_REG) + return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ sframe_fre_set_cfa_base_reg (cur_fre, cfi_insn->u.ri.reg); sframe_fre_set_cfa_offset (cur_fre, cfi_insn->u.ri.offset); cur_fre->merge_candidate = false; @@ -1006,9 +1010,14 @@ sframe_xlate_do_def_cfa_register (struct sframe_xlate_ctx *xlate_ctx, struct sframe_row_entry *last_fre = xlate_ctx->last_fre; /* Get the scratchpad FRE. This FRE will eventually get linked in. */ struct sframe_row_entry *cur_fre = xlate_ctx->cur_fre; + gas_assert (cur_fre); /* Define the current CFA rule to use the provided register (but to - keep the old offset). */ + keep the old offset). However, if the register is not FP/SP, + skip creating SFrame stack trace info for the function. */ + if (cfi_insn->u.r != SFRAME_CFA_SP_REG + && cfi_insn->u.r != SFRAME_CFA_FP_REG) + return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ sframe_fre_set_cfa_base_reg (cur_fre, cfi_insn->u.ri.reg); sframe_fre_set_cfa_offset (cur_fre, last_fre->cfa_offset); cur_fre->merge_candidate = false; diff --git a/ld/testsuite/ld-sframe/discard.s b/ld/testsuite/ld-sframe/discard.s index a438b42bffa1..5591a50d486a 100644 --- a/ld/testsuite/ld-sframe/discard.s +++ b/ld/testsuite/ld-sframe/discard.s @@ -5,7 +5,6 @@ foo: .cfi_startproc .cfi_def_cfa_offset 16 - .cfi_def_cfa 7, 8 .cfi_endproc .globl _start From patchwork Mon Jun 24 14:23:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92782 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 613E4384772F for ; Mon, 24 Jun 2024 19:00:48 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id E32FB385840D for ; Mon, 24 Jun 2024 19:00:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E32FB385840D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E32FB385840D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719255605; cv=none; b=WCts4rgNWPG38c5yw8RXUR2y+Zg7v1MM7ZZUKj7yPw01ezVpxxIgunCA6Pn8TAXW6v2qDBCm8ll6iUB7Qk/8a6Gi+OE5/btorm0LsutldQ2OPijbvPFts881x4HIjKKdEtjbRR8tS7Ff0HUR8oYrFQeI2wS/CNaXAmjfW+VrEeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719255605; c=relaxed/simple; bh=XK1lr/dRpZSKH9uzV8y7AIqVWDfC59/PWEZyPvfo8fY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=rTJKRv5p6Sbn+0IPaQoE16wm/sIafz4tMre46v9jbEPKggV8dXkHfzI592w9mcpx0tbgAoli9Usy5gXmy8l3VZ6pRSG4KBJjvgYyvxbU56ANLRvEjCumFV8BUNZTVk1AO5g1tIxDrWKakgvMdo5aXmtHyHMdk478nja29UmDkPs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45ODuwKa022465; Mon, 24 Jun 2024 14:27:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=Jmk37mZ/zQgOJ dKDFpxGQIgtQ7ExjgC1xk1R98Wwr48=; b=EbX27MHw1dAXtpSHCRpfT92VCwYZb 2ZgivIT8t7A3EiwZOtpOpv6kNERT90iiKiEwozV/nTb4iQnXCry2gKsN5eCJkeCE XspONYOUe4YtXKZZ1r0sbZ8EBA0b/WvJykVLRSKFSvlQCg+gJ7rDji60sZmeYTnb GuLlawkFpM1HZJWy4IsyAkXWu5NaVzXgRB+8GIu0txHSA9yRg0mF6TVsJNBAtYqB WScPOeJXRoIcqZhFMUsYEzk8jkes9uwb8fsI5nf+cCCDhwKnoOt0UmVV2qG8dnkl f336MOWYOHhcVBjsclxkhYzPGMdKGdrOrhq55YXjDiRhwCGdTBYW8oo7Q== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yy7y20gjn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:27:18 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45ODBUgE000627; Mon, 24 Jun 2024 14:23:44 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yxaems48e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:43 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENcwN56689144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:40 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 272F72006E; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D0F02006C; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 07/15] gas: Warn if SFrame FDE is skipped due to non-default return column Date: Mon, 24 Jun 2024 16:23:26 +0200 Message-Id: <20240624142334.3283823-8-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: S2NTm165Kz28pVGIPU59TFi6s_HySj9R X-Proofpoint-ORIG-GUID: S2NTm165Kz28pVGIPU59TFi6s_HySj9R X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org Print a warning message if SFrame FDE is skipped due to a non-default DWARF return column (i.e. return address (RA) register number). This may be caused by the use of CFI directive .cfi_return_column with a non-default return address (RA) register number in the processed assembler source code. Warning: skipping SFrame FDE due to non-default DWARF return column gas/ * gen-sframe.c: Warn if SFrame FDE is skipped due to non-default DWARF return column. gas/testsuite/ * gas/cfi-sframe/common-empty-3.d: Update test case to expect for new warning message when SFrame FDE is skipped due to a non-default DWARF return column. Reviewed-by: Andreas Krebbel Reviewed-by: Indu Bhagat Signed-off-by: Jens Remus --- Notes (jremus): Changes v2 -> v3: - Enhance comment in code as suggested by Indu. - Corrected formatting of ChangeLog in commit message. Without this patch the assembler would generate incomplete SFrame information without warning for the s390-specific SFrame error test case 4, that gets introduced by patch "s390: Initial support to generate .sframe from CFI directives in assembler". gas/gen-sframe.c | 10 +++++++--- gas/testsuite/gas/cfi-sframe/common-empty-3.d | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 52c2f3f4ff89..fac5b6f0fa62 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1345,9 +1345,12 @@ sframe_do_fde (struct sframe_xlate_ctx *xlate_ctx, xlate_ctx->dw_fde = dw_fde; - /* If the return column is not RIP, SFrame format cannot represent it. */ + /* SFrame format cannot represent a non-default DWARF return column reg. */ if (xlate_ctx->dw_fde->return_column != DWARF2_DEFAULT_RETURN_COLUMN) - return SFRAME_XLATE_ERR_NOTREPRESENTED; + { + as_warn (_("skipping SFrame FDE due to non-default DWARF return column")); + return SFRAME_XLATE_ERR_NOTREPRESENTED; + } /* Iterate over the CFIs and create SFrame FREs. */ for (cfi_insn = dw_fde->data; cfi_insn; cfi_insn = cfi_insn->next) @@ -1357,7 +1360,8 @@ sframe_do_fde (struct sframe_xlate_ctx *xlate_ctx, if (err != SFRAME_XLATE_OK) { /* Skip generating SFrame stack trace info for the function if any - offending CFI is encountered by sframe_do_cfi_insn (). */ + offending CFI is encountered by sframe_do_cfi_insn (). Warning + message already printed by sframe_do_cfi_insn (). */ return err; /* Return the error code. */ } } diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-3.d b/gas/testsuite/gas/cfi-sframe/common-empty-3.d index 5914c620760d..d17521dd88ea 100644 --- a/gas/testsuite/gas/cfi-sframe/common-empty-3.d +++ b/gas/testsuite/gas/cfi-sframe/common-empty-3.d @@ -1,4 +1,5 @@ #as: --gsframe +#warning: skipping SFrame FDE due to non-default DWARF return column #objdump: --sframe=.sframe #name: SFrame supports only default return column #... From patchwork Mon Jun 24 14:23:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92798 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 5B21A384609B for ; Tue, 25 Jun 2024 03:09:58 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id D286F3846423 for ; Tue, 25 Jun 2024 03:09:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D286F3846423 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D286F3846423 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719284973; cv=none; b=Omr1wJKeDOEUnWFzrvIVO0nLdIssB4gx6g/Y6WbBLaU3SAwQ8aWshhNlkAPmC8DvIB8/byiG+xJWtRd6gZxrdw3OqsbiakVoLJ9jLl6DgFbCqAdGGDPweqNkP+/L6+Ytf7Qw/PJwd0tlHIpkh7J5U/ue2tBXfqM5799zBPkW5J0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719284973; c=relaxed/simple; bh=/0C1DaS/gVSg0aAUnhZDkXBR06GDsvKQ/xR4tcig31g=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=bE1Cqon4BO2vA763ZH24c0CQ8CR/WBYGKO3CVNDNcMW2WE5RfYxFQqCTTOTuZMNqOQipRyhSs9+EZgv4vZ2L1Ae9gDfto521aNViP23j6YCBNt73X3XXIH2srlPNQSeba0+0gAIGcDS2hIsNtsHNZTRMV9NS0utnGNW3WQpY8aA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45ODwlYB007863; Mon, 24 Jun 2024 14:23:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=tY73wdM4Tku+j xlaGgSSH7E3/lYxoQpxovY/L0qE6eg=; b=iX81bfntvNhLLMkPCAEE9apaiIGoh G+4b00MS3yBdujav3feo8UaWyW+aJXKhoPDoDdslyDAGCT+CbM/Kfk+oyb0/T970 B3BUCEkQDsuz9oR5jTbgYnSR/SWXjZKQqqluMSa0mOXCpqeRn49ARCSkLhf9xLdq TOH58QWKfEW7wwzafXM3fHa869lMw1h9Ffdc1DbhJrg/iJignKJU8jnjhaEZ1yOu u4E7GUHA8WNSR3vzPA9hirtfKg6d+0n44qWs9vmWfFOSiBLRWHtmMSg4RZNCgM6j e3NcqebHD8Pc5lyxYdGntkinY8btl+Pg16y73yJ8GsiOOV3R69PJwNnJw== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yya5a82yp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:47 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45OD0Od5000564; Mon, 24 Jun 2024 14:23:46 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yxaems48j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:46 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENeHl49086944 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:42 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36B852006C; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 28E2120067; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 08/15] gas: Refactor SFrame CFI opcode DW_CFA_register processing Date: Mon, 24 Jun 2024 16:23:27 +0200 Message-Id: <20240624142334.3283823-9-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 1s75GvNu9iZc8Ql2SNtgAwQshbun7I6W X-Proofpoint-GUID: 1s75GvNu9iZc8Ql2SNtgAwQshbun7I6W X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=999 phishscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org Refactor SFrame processing of CFI opcode DW_CFA_register into a separate function. This harmonizes the CFI opcode processing. While at it reword the comment on CFI opcodes that are not processed. This is a purely mechanical change. gas/ * gen-sframe.c (sframe_do_cfi_insn, sframe_xlate_do_register): Refactor SFrame CFI opcode DW_CFA_register processing. Reviewed-by: Indu Bhagat Signed-off-by: Jens Remus --- Notes (jremus): Changes v2 -> v3: - New patch. gas/gen-sframe.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index fac5b6f0fa62..4809619f4636 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1110,6 +1110,28 @@ sframe_xlate_do_val_offset (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED, return SFRAME_XLATE_OK; } +/* Translate DW_CFA_register into SFrame context. + Return SFRAME_XLATE_OK if success. */ + +static int +sframe_xlate_do_register (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED, + struct cfi_insn_data *cfi_insn) +{ + /* Previous value of register1 is register2. However, if the specified + register1 is not interesting (SP, FP, or RA reg), the current DW_CFA_register + instruction can be safely skipped without sacrificing the asynchronicity of + stack trace information. */ + if (cfi_insn->u.rr.reg1 == SFRAME_CFA_SP_REG +#ifdef SFRAME_FRE_RA_TRACKING + || (cfi_insn->u.rr.reg1 == SFRAME_CFA_RA_REG) +#endif + || cfi_insn->u.rr.reg1 == SFRAME_CFA_FP_REG) + return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ + + /* Safe to skip. */ + return SFRAME_XLATE_OK; +} + /* Translate DW_CFA_remember_state into SFrame context. Return SFRAME_XLATE_OK if success. */ @@ -1298,19 +1320,12 @@ sframe_do_cfi_insn (struct sframe_xlate_ctx *xlate_ctx, case DW_CFA_GNU_window_save: err = sframe_xlate_do_gnu_window_save (xlate_ctx, cfi_insn); break; - /* Other CFI opcodes are not processed at this time. - These do not impact the coverage of the basic stack tracing - information as conveyed in the SFrame format. - - DW_CFA_register, - - etc. */ case DW_CFA_register: - if (cfi_insn->u.rr.reg1 == SFRAME_CFA_SP_REG -#ifdef SFRAME_FRE_RA_TRACKING - || cfi_insn->u.rr.reg1 == SFRAME_CFA_RA_REG -#endif - || cfi_insn->u.rr.reg1 == SFRAME_CFA_FP_REG) - err = SFRAME_XLATE_ERR_NOTREPRESENTED; + err = sframe_xlate_do_register (xlate_ctx, cfi_insn); break; + /* Following CFI opcodes are not processed at this time. + These do not impact the coverage of the basic stack tracing + information as conveyed in the SFrame format. */ case DW_CFA_undefined: case DW_CFA_same_value: break; From patchwork Mon Jun 24 14:23:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92826 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 8CBFA384475E for ; Tue, 25 Jun 2024 10:09:51 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id D05F7385B50C for ; Tue, 25 Jun 2024 10:09:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D05F7385B50C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D05F7385B50C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719310155; cv=none; b=PrC0M/trRfquY2GvTwWzAuaEh3XAQPTzBxJIVi7/hGK33CBVNY+ZobNDYUvl/QrKMK8ytRXloxx7H2K4MXcpuwO0GoBhCz2P6lgCqoj1jOejvHN/Nslq6VsmNyprWUzUEdKaCrmApBXheg/PHig3X0fhUvt1K63ljoB8FcZnxxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719310155; c=relaxed/simple; bh=IqCpipjM7uGpsH26QriUI/OJMXO77Ilp1bHbby2gK5A=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=beD+Ttxh7MEYJIP09V9ATVaxlAYLfwCiNOIJAJBVhj3o2P/KURcgOZA4NEMO/I7sg6/A19XslT/sig78gWrZKm/pSKMc5yrOBrKfDE0AYgF4c6zipxQfuUxZeKuvon3+m4kUUa5svAChhVBTfZhY5mT8hbjtdd/jJkUzGrru0x8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45OEQw9t005468; Mon, 24 Jun 2024 14:26:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=UCz2kNIAdCpvr qAOEvVaeq0/CG3Fr+c14B2OkbmGkOA=; b=JtDqhy444PV7cBQbLq0QaN33Flrz+ 01Y9lmyYRWLkh+E6OndYCBsq5eP2oi8oUFbfLTndx6Rn/Dd1bJsOO3uEcaHPQX2S 4/jTaUvuUMYz5g0Xxg9nuKetQTW/DUxvpyR7KfKw9MO93iLjACBpQcRCeKDb2nMJ Txa9MKgrlNDqDkTZmUo4HO5BM0fYAiIh5EVha1GCtBTvzHXSlk1Jyu3vcVKck2nx msC3SxyfnutPb7YTCd5fEX20AHKz93An4NBJnR3b/2ijGM6sW6glwMiTJDFTpU6d bnCRhWT2wXeHgqj039NCKw/AIT4tcCaqM+5IPM8Aenv3Hpm6RvEfTIg3Q== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yyae880k4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:26:58 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45OCa9mA019625; Mon, 24 Jun 2024 14:23:46 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yx9xps8bd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:45 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENeKG54657444 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:42 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6744820067; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44FB22005A; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 09/15] gas: User readable warnings if SFrame FDE is not generated Date: Mon, 24 Jun 2024 16:23:28 +0200 Message-Id: <20240624142334.3283823-10-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: nxoG1AeQR7pLbNv3a29k8oUYqRWhct_L X-Proofpoint-GUID: nxoG1AeQR7pLbNv3a29k8oUYqRWhct_L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 phishscore=0 clxscore=1015 mlxscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org The following generic warning message, which is printed whenever the assembler skips generation of SFrame FDE, is not very helpful for the user: skipping SFrame FDE; CFI insn (0x) Whenever possible print meaningful warning messages, when the assembler skips generation of SFrame FDE: - skipping SFrame FDE; non-SP/FP register in .cfi_def_cfa - skipping SFrame FDE; non-SP/FP register in .cfi_def_cfa_register - skipping SFrame FDE; .cfi_def_cfa_offset without CFA base register in effect - skipping SFrame FDE; {FP|RA} register in .cfi_val_offset - skipping SFrame FDE; {SP|FP|RA} register in in .cfi_register - skipping SFrame FDE; .cfi_remember_state without prior SFrame FRE state - skipping SFrame FDE; non-default RA register gas/ * gen-sframe.h (SFRAME_FRE_BASE_REG_INVAL): New macro for invalid SFrame FRE CFA base register value of -1. * gen-sframe.c: User readable warnings if SFrame FDE is not generated. gas/testsuite/ * gas/cfi-sframe/common-empty-1.d: Update generic SFrame test case to updated warning message texts. * gas/cfi-sframe/common-empty-2.d: Likewise. * gas/cfi-sframe/common-empty-3.d: Likewise. Reviewed-by: Andreas Krebbel Signed-off-by: Jens Remus --- Notes (jremus): Changes v3 -> v4: - Use terse warning message texts as suggested by Indu. - Fix bad indentation reported by GCC's check_GNU_style.py. Changes v2 -> v3: - Updated SFrame warning message texts as suggested by Indu, except for the .cfi_def_cfa[_register] ones. I think it would be helpful for the user to know that the issue is caused by a non-SP/FP register. But maybe that is because I am new to CFI and those that would actually debug the cause for these warnings would not need this extra information? Anyhow, Indu, if you still prefer your suggestions I would go with yours. The ".cfi_remember_state without SFrame FRE state" warning needs to remain, as there would otherwise not be any warning at all. The reason is that sframe_do_cfi_insn now expects any of its called CFI processing functions to emit a warning, if they return with an error, such as SFRAME_XLATE_ERR_NOTREPRESENTED. Silently skipping SFrame FDE does not seem an acceptable approach to me. - Do not test sframe_ra_tracking_p when determining the SFrame register name in sframe_register_name. The RA register name does not depend on whether RA tracking is used or not. - Corrected formatting of ChangeLog in commit message. gas/gen-sframe.c | 92 ++++++++++++++----- gas/gen-sframe.h | 2 + gas/testsuite/gas/cfi-sframe/common-empty-1.d | 2 +- gas/testsuite/gas/cfi-sframe/common-empty-2.d | 2 +- gas/testsuite/gas/cfi-sframe/common-empty-3.d | 2 +- 5 files changed, 72 insertions(+), 28 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 4809619f4636..3d9824a7a080 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -869,7 +869,7 @@ sframe_row_entry_new (void) struct sframe_row_entry *fre = XCNEW (struct sframe_row_entry); /* Reset cfa_base_reg to -1. A value of 0 will imply some valid register for the supported arches. */ - fre->cfa_base_reg = -1; + fre->cfa_base_reg = SFRAME_FRE_BASE_REG_INVAL; fre->merge_candidate = true; /* Reset the mangled RA status bit to zero by default. We will initialize it in sframe_row_entry_initialize () with the sticky bit if set. */ @@ -924,6 +924,23 @@ sframe_row_entry_initialize (struct sframe_row_entry *cur_fre, cur_fre->mangled_ra_p = prev_fre->mangled_ra_p; } +/* Return SFrame register name for SP, FP, and RA, or NULL if other. */ + +static const char * +sframe_register_name (unsigned int reg) +{ + if (reg == SFRAME_CFA_SP_REG) + return "SP"; + else if (reg == SFRAME_CFA_FP_REG) + return "FP"; +#ifdef SFRAME_FRE_RA_TRACKING + else if (reg == SFRAME_CFA_RA_REG) + return "RA"; +#endif + else + return NULL; +} + /* Translate DW_CFA_advance_loc into SFrame context. Return SFRAME_XLATE_OK if success. */ @@ -992,7 +1009,11 @@ sframe_xlate_do_def_cfa (struct sframe_xlate_ctx *xlate_ctx, SFrame stack trace info for the function. */ if (cfi_insn->u.r != SFRAME_CFA_SP_REG && cfi_insn->u.r != SFRAME_CFA_FP_REG) - return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ + { + as_warn (_("skipping SFrame FDE; non-SP/FP register %u in .cfi_def_cfa"), + cfi_insn->u.r); + return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ + } sframe_fre_set_cfa_base_reg (cur_fre, cfi_insn->u.ri.reg); sframe_fre_set_cfa_offset (cur_fre, cfi_insn->u.ri.offset); cur_fre->merge_candidate = false; @@ -1017,7 +1038,12 @@ sframe_xlate_do_def_cfa_register (struct sframe_xlate_ctx *xlate_ctx, skip creating SFrame stack trace info for the function. */ if (cfi_insn->u.r != SFRAME_CFA_SP_REG && cfi_insn->u.r != SFRAME_CFA_FP_REG) - return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ + { + as_warn (_("skipping SFrame FDE; " + "non-SP/FP register %u in .cfi_def_cfa_register"), + cfi_insn->u.r); + return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ + } sframe_fre_set_cfa_base_reg (cur_fre, cfi_insn->u.ri.reg); sframe_fre_set_cfa_offset (cur_fre, last_fre->cfa_offset); cur_fre->merge_candidate = false; @@ -1048,7 +1074,13 @@ sframe_xlate_do_def_cfa_offset (struct sframe_xlate_ctx *xlate_ctx, cur_fre->merge_candidate = false; } else - return SFRAME_XLATE_ERR_NOTREPRESENTED; + { + /* No CFA base register in effect. Non-SP/FP CFA base register should + not occur, as sframe_xlate_do_def_cfa[_register] would detect this. */ + as_warn (_("skipping SFrame FDE; " + ".cfi_def_cfa_offset without CFA base register in effect")); + return SFRAME_XLATE_ERR_NOTREPRESENTED; + } return SFRAME_XLATE_OK; } @@ -1098,13 +1130,16 @@ sframe_xlate_do_val_offset (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED, register is not interesting (FP or RA reg), the current DW_CFA_val_offset instruction can be safely skipped without sacrificing the asynchronicity of stack trace information. */ - if (cfi_insn->u.r == SFRAME_CFA_FP_REG) - return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ + if (cfi_insn->u.r == SFRAME_CFA_FP_REG #ifdef SFRAME_FRE_RA_TRACKING - else if (sframe_ra_tracking_p () - && cfi_insn->u.r == SFRAME_CFA_RA_REG) - return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ + || (sframe_ra_tracking_p () && cfi_insn->u.r == SFRAME_CFA_RA_REG) #endif + ) + { + as_warn (_("skipping SFrame FDE; %s register %u in .cfi_val_offset"), + sframe_register_name (cfi_insn->u.r), cfi_insn->u.r); + return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ + } /* Safe to skip. */ return SFRAME_XLATE_OK; @@ -1126,7 +1161,11 @@ sframe_xlate_do_register (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED, || (cfi_insn->u.rr.reg1 == SFRAME_CFA_RA_REG) #endif || cfi_insn->u.rr.reg1 == SFRAME_CFA_FP_REG) - return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ + { + as_warn (_("skipping SFrame FDE; %s register %u in .cfi_register"), + sframe_register_name (cfi_insn->u.rr.reg1), cfi_insn->u.rr.reg1); + return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ + } /* Safe to skip. */ return SFRAME_XLATE_OK; @@ -1144,7 +1183,11 @@ sframe_xlate_do_remember_state (struct sframe_xlate_ctx *xlate_ctx) early with non-zero error code, this will cause no SFrame stack trace info for the function involved. */ if (!last_fre) - return SFRAME_XLATE_ERR_INVAL; + { + as_warn (_("skipping SFrame FDE; " + ".cfi_remember_state without prior SFrame FRE state")); + return SFRAME_XLATE_ERR_INVAL; + } if (!xlate_ctx->remember_fre) xlate_ctx->remember_fre = sframe_row_entry_new (); @@ -1332,21 +1375,19 @@ sframe_do_cfi_insn (struct sframe_xlate_ctx *xlate_ctx, default: /* Following skipped operations do, however, impact the asynchronicity: - CFI_escape. */ - err = SFRAME_XLATE_ERR_NOTREPRESENTED; - } - - /* An error here will cause no SFrame FDE later. Warn the user because this - will affect the overall coverage and hence, asynchronicity. */ - if (err) - { - const char *cfi_name = sframe_get_cfi_name (op); - - if (!cfi_name) - cfi_name = _("(unknown)"); - as_warn (_("skipping SFrame FDE; CFI insn %s (%#x)"), - cfi_name, op); + { + const char *cfi_name = sframe_get_cfi_name (op); + + if (!cfi_name) + cfi_name = _("(unknown)"); + as_warn (_("skipping SFrame FDE; CFI insn %s (%#x)"), + cfi_name, op); + err = SFRAME_XLATE_ERR_NOTREPRESENTED; + } } + /* Any error will cause no SFrame FDE later. The user has already been + warned. */ return err; } @@ -1363,7 +1404,8 @@ sframe_do_fde (struct sframe_xlate_ctx *xlate_ctx, /* SFrame format cannot represent a non-default DWARF return column reg. */ if (xlate_ctx->dw_fde->return_column != DWARF2_DEFAULT_RETURN_COLUMN) { - as_warn (_("skipping SFrame FDE due to non-default DWARF return column")); + as_warn (_("skipping SFrame FDE; non-default RA register %u"), + xlate_ctx->dw_fde->return_column); return SFRAME_XLATE_ERR_NOTREPRESENTED; } diff --git a/gas/gen-sframe.h b/gas/gen-sframe.h index fbe2fd5d9368..8ed46dbb087b 100644 --- a/gas/gen-sframe.h +++ b/gas/gen-sframe.h @@ -24,6 +24,8 @@ #define SFRAME_FRE_ELEM_LOC_REG 0 #define SFRAME_FRE_ELEM_LOC_STACK 1 +#define SFRAME_FRE_BASE_REG_INVAL ((unsigned int)-1) + /* SFrame Frame Row Entry (FRE). A frame row entry is a slice of the frame and can be valid for a set of diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-1.d b/gas/testsuite/gas/cfi-sframe/common-empty-1.d index dbb48949c713..6e99dd57af94 100644 --- a/gas/testsuite/gas/cfi-sframe/common-empty-1.d +++ b/gas/testsuite/gas/cfi-sframe/common-empty-1.d @@ -1,5 +1,5 @@ #as: --gsframe -#warning: skipping SFrame FDE; CFI insn DW_CFA_remember_state \(0xa\) +#warning: skipping SFrame FDE; \.cfi_remember_state without prior SFrame FRE state #objdump: --sframe=.sframe #name: Uninteresting cfi directives generate an empty SFrame section #... diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-2.d b/gas/testsuite/gas/cfi-sframe/common-empty-2.d index 7b2ce3e8c796..77c303eec8fb 100644 --- a/gas/testsuite/gas/cfi-sframe/common-empty-2.d +++ b/gas/testsuite/gas/cfi-sframe/common-empty-2.d @@ -1,5 +1,5 @@ #as: --gsframe -#warning: skipping SFrame FDE; CFI insn DW_CFA_def_cfa_offset \(0xe\) +#warning: skipping SFrame FDE; \.cfi_def_cfa_offset without CFA base register in effect #objdump: --sframe=.sframe #name: SFrame supports only FP/SP based CFA #... diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-3.d b/gas/testsuite/gas/cfi-sframe/common-empty-3.d index d17521dd88ea..4ec5b44dd51f 100644 --- a/gas/testsuite/gas/cfi-sframe/common-empty-3.d +++ b/gas/testsuite/gas/cfi-sframe/common-empty-3.d @@ -1,5 +1,5 @@ #as: --gsframe -#warning: skipping SFrame FDE due to non-default DWARF return column +#warning: skipping SFrame FDE; non-default RA register 0 #objdump: --sframe=.sframe #name: SFrame supports only default return column #... From patchwork Mon Jun 24 14:23:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92777 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 77FED384AB4E for ; Mon, 24 Jun 2024 16:56:59 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id B501D3858D35 for ; Mon, 24 Jun 2024 16:56:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B501D3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B501D3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719248193; cv=none; b=bjbMmt2tKw3blAd2eH/GUtkDY+qGxSiNs1uU6+yAoUXKzDBGPnWwzeLfpxhC71vmjaDO8Pwj3LgNKrH42x4Vv9qNY6W+Sscj2VFo4FjQFmnSvm6GzeEIiGk8yvyS44ddSv4EjDlL5jVLwUQRVmEZAowFgUPUrrqNpbfTPbJmF1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719248193; c=relaxed/simple; bh=BtXe62wsqQerdJZ68IEoskyb4TlmgVvEgUO1V0mZr8Q=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=VqHivl1mXVnz+05eNFePpQo94ITTHQ9afj7BrdooBaV0vYFVQ6eZjQTzHsroI98+l5PumE7bMCtSxlDEU2aep2Q7kqAwhU+59vMAO+AhptUHwwOw1uD+fU8GNarw0SJNyj5+9SRh/HvDo/1rAZ56Hs65AlOM3iyddYOAJRctaBk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45OEQn9o010590; Mon, 24 Jun 2024 14:26:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=hvflbSFxIajPk gD9LLwwkJA+wXNufJntIX8YZMPudkA=; b=iaYsjTCFtEFX2gtC5Caqg8Eg6B9wz R8aIkWhYJXzLk5OcheAUn97M1rX/CeYkrzSdXytulRspHfDZ8e87svBqlaYh+s38 zArR4XUyqwyKAWzYKYdRDq6wELd02gR5nYcXErdFRidKOGKeWdkaotW/4qNMpA+b 2uMDtZyqjftiR4FcKwQZeGM20kOSB0DEhFhoGeHmV81SmjaGZ4eUb+SEQWYwpM4E yRjXfUNRZ8dzwjtsJPXuxd1eB6pPOS6LPZdr0tCdgTGTXgS07GLoULJVoOkDT2Qh vMCn216gZNwIV3ViHsuB6xSrdBqOjrK4XsFjfTUOW0qdF+LRp6Jk6EHpA== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yy8u4rah3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:26:49 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45OBwH6A018093; Mon, 24 Jun 2024 14:23:45 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yx8xu1eu1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:45 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENeQF56099092 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:42 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82D792005A; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6898D20071; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 10/15] gas: Skip SFrame FDE if FP without RA on stack Date: Mon, 24 Jun 2024 16:23:29 +0200 Message-Id: <20240624142334.3283823-11-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ZGCbTn-Dxc00rtA1F-9-sLxHd0BFQJoo X-Proofpoint-GUID: ZGCbTn-Dxc00rtA1F-9-sLxHd0BFQJoo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 priorityscore=1501 adultscore=0 clxscore=1015 malwarescore=0 bulkscore=0 impostorscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org The SFrame format cannot represent the frame pointer (FP) being saved on the stack without the return address (RA) also being saved on the stack, if RA tracking is used. A SFrame FDE is followed by 1-3 offsets with the following information: Without RA tracking: 1. Offset from base pointer (SP or FP) to locate the CFA 2. Optional: Offset to CFA to restore the frame pointer (FP) With RA tracking: 1. Offset from base pointer (SP or FP) to locate the CFA 2. Optional: Offset to CFA to restore the return address (RA) 3. Optional: Offset to CFA to restore the frame pointer (FP) When RA tracking is used and a FDE is followed by two offsets the SFrame format does not provide any information to distinguish whether the second offset is the RA or FP offset. SFrame assumes the offset to be the RA offset, which may be wrong. Therefore skip generation of SFrame FDE information and print the following warning, if RA tracking is used and the FP is saved on the stack without the RA being saved as well: skipping SFrame FDE; FP without RA on stack gas/ * gen-sframe.c (sframe_do_fde): Skip SFrame FDE if FP without RA on stack, as the SFrame format cannot represent this case. Reviewed-by: Indu Bhagat Signed-off-by: Jens Remus --- Notes (jremus): Changes v3 -> v4: - Dropped misleading comment "No errors encountered". as suggtested by Indu. - Changed warning message text as follows for consistency: skipping SFrame FDE; FP without RA on stack Changes v2 -> v3: - New patch. Without this patch the assembler would generate incorrect SFrame information without warning for the s390-specific SFrame error test case 5, that gets introduced by patch "s390: Initial support to generate .sframe from CFI directives in assembler". The FRE would be followed by two offsets for the CFA and FP. SFrame would erroneously interpret them as CFA and RA offsets, as it cannot represent FP without RA on stack. gas/gen-sframe.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 3d9824a7a080..c29c407cc86f 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1423,8 +1423,6 @@ sframe_do_fde (struct sframe_xlate_ctx *xlate_ctx, } } - /* No errors encountered. */ - /* Link in the scratchpad FRE that the last few CFI insns helped create. */ if (xlate_ctx->cur_fre) { @@ -1438,6 +1436,25 @@ sframe_do_fde (struct sframe_xlate_ctx *xlate_ctx, = get_dw_fde_end_addrS (xlate_ctx->dw_fde); } +#ifdef SFRAME_FRE_RA_TRACKING + if (sframe_ra_tracking_p ()) + { + struct sframe_row_entry *fre; + + /* Iterate over the scratchpad FREs and validate them. */ + for (fre = xlate_ctx->first_fre; fre; fre = fre->next) + { + /* SFrame format cannot represent FP on stack without RA on stack. */ + if (fre->ra_loc != SFRAME_FRE_ELEM_LOC_STACK + && fre->bp_loc == SFRAME_FRE_ELEM_LOC_STACK) + { + as_warn (_("skipping SFrame FDE; FP without RA on stack")); + return SFRAME_XLATE_ERR_NOTREPRESENTED; + } + } + } +#endif /* SFRAME_FRE_RA_TRACKING */ + return SFRAME_XLATE_OK; } From patchwork Mon Jun 24 14:23:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92796 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 8C1143846089 for ; Tue, 25 Jun 2024 02:09:04 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 1FCDA384AB7D for ; Tue, 25 Jun 2024 02:08:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1FCDA384AB7D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1FCDA384AB7D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719281300; cv=none; b=h1bllSlXJBqUBIWPnubTZwunodWYb/gvLC0qeiCmfBLrpIIb1hVEjN3ALSloai/JjrZCSd/zVtxzM3vWgWI2YcyjnDvka46uXiR1IjZ8EFNDVBVXlSYEKE4pWeOS1XSBoDLO6xOyM7JOetUCKj8uoifvZDkodmo81guZO2NlJLU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719281300; c=relaxed/simple; bh=grkfOpsEMZpAeLGixOqy4ysT6ZyfJC6uCqwbmZrYuIo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=obsWknG6S1jyNptQcl2BpicIw5iHXl69gPZEeAD9KumqM5hA7wDr32N0VlENsfe/NsafXi9avZ4psy3tj1YXHKh5yJdzhrSALdSNjI3dkDUl+qhX+TrpHfVa04L8SJauFTy56s4eWIMWL33wnEeKLN0T++Avfok4yZmuq61DktI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45OELfE5031419; Mon, 24 Jun 2024 14:27:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=R3Acxo4IZU42D Kfli8vQ+dwL9Rv8j23bko9i8sEerdw=; b=We+dNbV0Y/FP8LYnkm5IJNozX8E+T Gjhwz6mqC7aDXGeRgqeQKEhHsFT5FB8vJAhrqdqhJVx1zOL8un4szE6/b1zYUH7j JqQGhxrCKTTAr8UzYetGoWXNu3kiDTU7NXEHlOPbgHS8hdVGvHbDDe9wg4lagkev sPHd3AQfDLLTIHktGyOVrIf1NF1EIj9Jn+IgChC+Zq50NIq6fLWQkO3mCcq+48Nu lY3iK1l4lxggt1l8xcEdspGJlkWcQnhWemEkyCuM0kqMhoz94zTVy6ENr2aYtow2 w2PnN5Z0dkvqGT+rkxlYfW98+ryJQ2QRL8/1yM4TD9Cp7lVe7pZ2gIvuQ== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yya59g2tk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:27:06 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45OC8nAK018132; Mon, 24 Jun 2024 14:23:45 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yx8xu1eu2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:45 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENenj53477706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:42 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 91A8E20074; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 842FA20073; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 11/15] gas: Skip SFrame FDE if .cfi_window_save Date: Mon, 24 Jun 2024 16:23:30 +0200 Message-Id: <20240624142334.3283823-12-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: -vc3DY3-6VQluwHpgXMHoyPEvokMPDS- X-Proofpoint-ORIG-GUID: -vc3DY3-6VQluwHpgXMHoyPEvokMPDS- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=999 clxscore=1015 mlxscore=0 malwarescore=0 spamscore=0 suspectscore=0 bulkscore=0 impostorscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org CFI opcode DW_CFA_AARCH64_negate_ra_state is multiplexed with DW_CFA_GNU_window_save. Process DW_CFA_AARCH64_negate_ra_state on AArch64. Skip generation of SFrame FDE otherwise with the following warning message: skipping SFrame FDE; .cfi_window_save gas/ * gen-sframe.c: Skip SFrame FDE if .cfi_window_save. Reviewed-by: Indu Bhagat Signed-off-by: Jens Remus --- Notes (jremus): Changes v3 -> v4: - Change warning message text to the following for consistency: skipping SFrame FDE; .cfi_window_save Changes v2 -> v3: - New patch. The intention is to skip all "unknown" CFI opcodes, which SFrame does not explicitly handle. DW_CFA_GNU_window_save seems to be handled only for the AArch64-specific multiplexed DW_CFA_AARCH64_negate_ra_state. The logic could be changed to be dependent on TC_AARCH64 at build-time instead of sframe_get_abi_arch() at run-time. gas/gen-sframe.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index c29c407cc86f..2222d768799f 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1256,12 +1256,12 @@ sframe_xlate_do_restore (struct sframe_xlate_ctx *xlate_ctx, return SFRAME_XLATE_OK; } -/* Translate DW_CFA_GNU_window_save into SFrame context. +/* Translate DW_CFA_AARCH64_negate_ra_state into SFrame context. Return SFRAME_XLATE_OK if success. */ static int -sframe_xlate_do_gnu_window_save (struct sframe_xlate_ctx *xlate_ctx, - struct cfi_insn_data *cfi_insn ATTRIBUTE_UNUSED) +sframe_xlate_do_aarch64_negate_ra_state (struct sframe_xlate_ctx *xlate_ctx, + struct cfi_insn_data *cfi_insn ATTRIBUTE_UNUSED) { struct sframe_row_entry *cur_fre = xlate_ctx->cur_fre; @@ -1273,6 +1273,25 @@ sframe_xlate_do_gnu_window_save (struct sframe_xlate_ctx *xlate_ctx, return SFRAME_XLATE_OK; } +/* Translate DW_CFA_GNU_window_save into SFrame context. + DW_CFA_AARCH64_negate_ra_state is multiplexed with DW_CFA_GNU_window_save. + Return SFRAME_XLATE_OK if success. */ + +static int +sframe_xlate_do_gnu_window_save (struct sframe_xlate_ctx *xlate_ctx, + struct cfi_insn_data *cfi_insn) +{ + unsigned char abi_arch = sframe_get_abi_arch (); + + /* Translate DW_CFA_AARCH64_negate_ra_state into SFrame context. */ + if (abi_arch == SFRAME_ABI_AARCH64_ENDIAN_BIG + || abi_arch == SFRAME_ABI_AARCH64_ENDIAN_LITTLE) + return sframe_xlate_do_aarch64_negate_ra_state (xlate_ctx, cfi_insn); + + as_warn (_("skipping SFrame FDE; .cfi_window_save")); + return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ +} + /* Returns the DWARF call frame instruction name or fake CFI name for the specified CFI opcode, or NULL if the value is not recognized. */ From patchwork Mon Jun 24 14:23:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92781 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 D19403858D35 for ; Mon, 24 Jun 2024 18:57:30 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 7B7A03858D35 for ; Mon, 24 Jun 2024 18:56:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7B7A03858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7B7A03858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719255420; cv=none; b=OgJ+cDYRTQc4GRi1PjewyocnGYJbM3Bf/0umTRqYTxWmEzP53eu6Si7juAObh7KxwTxCEAHWSDc8TAbzOfn3bdE05F/PhgFrz0CDUoxxbM8MTqJgwGHEQuRMT/21jVrG3Bjxp8TEWi7ygmIvjRjf1L8K3SKyaq6qOy99MEo6AlQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719255420; c=relaxed/simple; bh=hCozZyNuTxa9BUNYlpKH4z0GjQC15ZD9DWRFv3KfbjI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=F3uTSOUGxKluVxfaTBie1swDdx3PaW5lLwigq7VKEZboVhw58FeOOnOJYTamokMOxczrZHUsbaAvAalDFGzu0hNHVuYPF4CFUcDRwDtZlM3BqZMqE2Z8Ijb/Cbc6YlB+jy99gJOXOzPZVTflW5/ngM94I+VJwYwaMnHVplbw0L4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45OEJDxK024973; Mon, 24 Jun 2024 14:26:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=81utJKURdRuna 9LIqUMsv7DfOPnUknsktu5hx5+HjdU=; b=Xl3dJDri83aoBRZSTUYdVGNN7fh7n yNMVICksMRYoSBFohXlRcCuwrWgsrs8ZFgLnWbzj9liQBKGV5ApBJxe3fEh7lqbq 7lRL9QM+ZZEy8VKQ+x7ren2goqo2YTVOdOAzWadQlpc1aAi/my7WShoJ0ksNOmGG Nhli47udbQf8vVM8RvSVFee0J6IeU/5yerkrD766BGmLb5mvRpgTd5osVZojJ/yn FE9msApCBRZ6hGvofTPBXPCsh/IPHlFWkQrPPqeAIJ2vjK09JLUT3irfeAuuJ+NO 6FbFRKvrRw/oYu9VawXuC2CppWaTRN4b7m+aNQ3h1PWpaWVBeQNXuN5Gg== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yyae880k5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:26:58 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45OCTImY019602; Mon, 24 Jun 2024 14:23:46 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yx9xps8be-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:45 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENe2b54395334 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:42 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C033220073; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9F8C120071; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 12/15] gas: Don't skip SFrame FDE if .cfi_register specifies RA w/o tracking Date: Mon, 24 Jun 2024 16:23:31 +0200 Message-Id: <20240624142334.3283823-13-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ImuJgNJOlcObaBO1FhD4eTZtTIuFblXB X-Proofpoint-GUID: ImuJgNJOlcObaBO1FhD4eTZtTIuFblXB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 phishscore=0 clxscore=1015 mlxscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org Do not skip SFrame FDE if .cfi_register specifies RA register without RA tracking being actually used. Without RA tracking the register contents can always be restored from the stack using the fixed RA offset from CFA. gas/ * gen-sframe.c (sframe_xlate_do_register): Do not skip SFrame FDE if .cfi_register specifies RA register without RA tracking being used. Reviewed-by: Indu Bhagat Signed-off-by: Jens Remus --- Notes (jremus): Changes v2 -> v3: - New patch. gas/gen-sframe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 2222d768799f..31f2e5118280 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1158,7 +1158,7 @@ sframe_xlate_do_register (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED, stack trace information. */ if (cfi_insn->u.rr.reg1 == SFRAME_CFA_SP_REG #ifdef SFRAME_FRE_RA_TRACKING - || (cfi_insn->u.rr.reg1 == SFRAME_CFA_RA_REG) + || (sframe_ra_tracking_p () && cfi_insn->u.rr.reg1 == SFRAME_CFA_RA_REG) #endif || cfi_insn->u.rr.reg1 == SFRAME_CFA_FP_REG) { From patchwork Mon Jun 24 14:23:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92780 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 93962384AB58 for ; Mon, 24 Jun 2024 17:55:51 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id B4F39385843B for ; Mon, 24 Jun 2024 17:55:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4F39385843B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B4F39385843B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719251716; cv=none; b=xEOBt53E/Kye/N02USOBmjCKPmuFM7o0Bq+Rnj66XZTjG0Ib7uAXLY4SegumcJMimeNSAsn01s5LLkqzDgqdquC+D4/3DlIph7In+Bz0ME0+0hVCM/+yIENBL+2XyRazfQt0z9yypwBm8WYZtuivXXkYOfDZzRmlKC1Qtu8U3Ks= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719251716; c=relaxed/simple; bh=o2P985bMSzUhSWEFIHYLFCcabN4AJXutl/jH9s9VwXc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=lfN6KfGwXD/N0naej5neNTfZLqwZmTn8NCTM6kyqSYs6drQ+Q5tRHj4hxLmYik/2cCPlxz9jWqIBr2TYCPnudSS5XiT7daCR9Kl+3+b7O9Pkp8Gxef9RdZ86na59gqWnQEyykbydLNcRWhHxFQ/gCRpU0mBfEjss+TJR1xhGAT4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45OERoi5005837; Mon, 24 Jun 2024 14:44:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=AuX8Ogr15cNmt SsUffjhCCfUvDU8cRMnCkjRjs2v7f0=; b=QiWXqdnCh4QUYZhXcV6a9Cy63QVTO yRr2HSYDn1q75QPUro0/+nrs8BaipwX8i7QR+sG1F8BJ3cipHvT7aMHwhMfvxq4x 9CyIP5SbGdngc75eerxdRbllOh2Be+kUvYE/Dm0wMAw5S9tDMc8Y/jKDHXaE0lND Y3t+C5hawXtOafBx2/vUORU1KTkO2yn+R0A/YvYQvKgcEeq+YX0w1uTxAB7sP9nb k22tNEFCVs3RZt+WdCgmf98Fxczl1dojiY0dENC64Hmh6TOTWKXadXFXpqQp74qp qQqM3fGaXUDg5Nqh4eyoxt2od9Qyg3MAjzacilwP0rA9htz+ocyG+hMxg== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yy99709nm-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:44:34 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45ODJLrE000685; Mon, 24 Jun 2024 14:23:45 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yxaems48g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:44 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENdQK22610674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:41 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB82620071; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C46A720075; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 13/15] gas: Don't skip SFrame FDE if .cfi_register specifies SP register Date: Mon, 24 Jun 2024 16:23:32 +0200 Message-Id: <20240624142334.3283823-14-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 8SF0p0BfwP6sq49t_FuiOQRwFJZ5z_xX X-Proofpoint-GUID: 8SF0p0BfwP6sq49t_FuiOQRwFJZ5z_xX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org Neither ".cfi_offset SP, ", ".cfi_register SP, ", nor ".cfi_val_offset SP, " alter the tracking information to recover the stack pointer (SP). Doing so would need an explicit .cfi_def_cfa, which SFrame tracks. The stack-pointer (SP) register contents on entry can be reconstructed from the SFrame CFA tracking information using information from the current and initial SFrame FREs of the SFrame FDE: 1. Compute CFA from the current CFA base register (SP or FP) and CFA offset from the SFrame CFA tracking information from the SFrame FRE for the current instruction address: CFA = + 2. Compute SP from the current CFA and the CFA offset from the SFrame CFA tracking information from the initial SFrame FRE of the FDE: SP = CFA - While at it add comments to the processing of .cfi_offset and .cfi_val_offset that the SP can be reconstructed from the CFA tracking information. gas/ * gen-sframe.c (sframe_xlate_do_register): Do not skip SFrame FDE if .cfi_register specifies SP register. (sframe_xlate_do_offset,sframe_xlate_do_val_offset): Add comment that this is likewise. Signed-off-by: Jens Remus --- Notes (jremus): Changes v3 -> v4: - Add comment to sframe_xlate_do_offset why SP register is ignored. - Reword commit message accordingly. Changes v2 -> v3: - New patch. gas/gen-sframe.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 31f2e5118280..f4bdbb5944d9 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1100,6 +1100,7 @@ sframe_xlate_do_offset (struct sframe_xlate_ctx *xlate_ctx, gas_assert (cur_fre); /* Change the rule for the register indicated by the register number to be the specified offset. */ + /* Ignore SP reg, as it can be recovered from the CFA tracking info. */ if (cfi_insn->u.r == SFRAME_CFA_FP_REG) { gas_assert (!cur_fre->base_reg); @@ -1134,6 +1135,7 @@ sframe_xlate_do_val_offset (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED, #ifdef SFRAME_FRE_RA_TRACKING || (sframe_ra_tracking_p () && cfi_insn->u.r == SFRAME_CFA_RA_REG) #endif + /* Ignore SP reg, as it can be recovered from the CFA tracking info. */ ) { as_warn (_("skipping SFrame FDE; %s register %u in .cfi_val_offset"), @@ -1153,14 +1155,15 @@ sframe_xlate_do_register (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED, struct cfi_insn_data *cfi_insn) { /* Previous value of register1 is register2. However, if the specified - register1 is not interesting (SP, FP, or RA reg), the current DW_CFA_register + register1 is not interesting (FP or RA reg), the current DW_CFA_register instruction can be safely skipped without sacrificing the asynchronicity of stack trace information. */ - if (cfi_insn->u.rr.reg1 == SFRAME_CFA_SP_REG + if (cfi_insn->u.rr.reg1 == SFRAME_CFA_FP_REG #ifdef SFRAME_FRE_RA_TRACKING || (sframe_ra_tracking_p () && cfi_insn->u.rr.reg1 == SFRAME_CFA_RA_REG) #endif - || cfi_insn->u.rr.reg1 == SFRAME_CFA_FP_REG) + /* Ignore SP reg, as it can be recovered from the CFA tracking info. */ + ) { as_warn (_("skipping SFrame FDE; %s register %u in .cfi_register"), sframe_register_name (cfi_insn->u.rr.reg1), cfi_insn->u.rr.reg1); From patchwork Mon Jun 24 14:23:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92799 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 6675A384609F for ; Tue, 25 Jun 2024 03:12:01 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id A95973846082 for ; Tue, 25 Jun 2024 03:11:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A95973846082 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A95973846082 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719285095; cv=none; b=Q5XXOCCbp1E6M45aoTzclvn7zVxT4ccF17frsjeHBohZNlpByXOAvDEHamQdAp3QKHhJ5zlAlVlvxkmaeQZdL3mCmqzghMNBSjyB95+8T2HLlybywF+Avp0+hGYMjH9X5HuTsQKdt9uLdt7PmQ14oQnlKzGz7yW8Z7QB75neazE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719285095; c=relaxed/simple; bh=KHJy5uU7LuIl1XtQt6tO127Z2QnKws/+mKKJUIV8jTk=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=PjkSRcaxoO7jxcmwIfjcB1aiKwVc6ehvpFOLIuj4D80BiDQ3pa7MsEAYpyil5JT5mVY92oGfVUCAJxGCxvVd/oeFMVf8a1xXq2N0ZkWY7Qt6a3puXWbFvlDTWzgZmsc9kGE9XGVWuJlz5d00EW4/6Ws+ctkwwJ6sduz0+mhL8Pc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45ODwZSE007758; Mon, 24 Jun 2024 14:23:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=Js13Sb24x9XWI pakPssBOQIJow83Z2twz/6axen8Jqo=; b=Iuo6Cvhs5SjiNBlEbMnG7Eydkr8+u RKMTy2PuYjCIWqHQq1Sqm5pAKIC51V9l/XXJZGrsuhBGGQzstMXVZaBV5OFyR6hB 0YujJaBiCgV7Ajb1r0iiQsp0iAbxveQM68S04xI026OVX9kytRVxpUFqa2D76kTW ZJwdmqBrUKAoBCSTmxxslbmTyIshXbdKKj1gvz7EPe6a4AL3eIskrIICgI7bKhuj tv1L45uZ6sc1J1YR+iXDUEhFQe47cN/kODA+D2A1QOekgfVAD3v1DM5VgB0ayBxB EFW+xCg9n3P6lcBN/9s/h2S8xiblnNBGGE2w+Refcl5rePugaQYN+c7PA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yya5a82yh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:46 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45OCTImX019602; Mon, 24 Jun 2024 14:23:45 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yx9xps8bb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:44 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENd0Y11862510 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:41 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 02B5C20077; Mon, 24 Jun 2024 14:23:39 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DFFEA20076; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 14/15] gas: Test predicate whether SFrame RA tracking is used Date: Mon, 24 Jun 2024 16:23:33 +0200 Message-Id: <20240624142334.3283823-15-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: cnNcWNvL9GbvHXlxFkA6hd-HnJu9axG6 X-Proofpoint-GUID: cnNcWNvL9GbvHXlxFkA6hd-HnJu9axG6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=999 phishscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org The existence of the macro SFRAME_FRE_RA_TRACKING only ensures the existence of the macro SFRAME_CFA_RA_REG and the predicate function sframe_ra_tracking_p. It does not indicate whether SFrame RA tracking is actually used. Test the return value of the SFrame RA tracking predicate function sframe_ra_tracking_p to determine whether RA tracking is used. This aligns the logic in functions get_fre_num_offsets and output_sframe_row_entry to the one used in all other places. gas/ * gen-sframe.c (get_fre_num_offsets, output_sframe_row_entry): Test predicate to determine whether SFrame RA tracking is used. Reviewed-by: Indu Bhagat Signed-off-by: Jens Remus --- Notes (jremus): Changes v2 -> v3: - New patch. gas/gen-sframe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index f4bdbb5944d9..f83a64518c28 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -346,7 +346,8 @@ get_fre_num_offsets (struct sframe_row_entry *sframe_fre) if (sframe_fre->bp_loc == SFRAME_FRE_ELEM_LOC_STACK) fre_num_offsets++; #ifdef SFRAME_FRE_RA_TRACKING - if (sframe_fre->ra_loc == SFRAME_FRE_ELEM_LOC_STACK) + if (sframe_ra_tracking_p () + && sframe_fre->ra_loc == SFRAME_FRE_ELEM_LOC_STACK) fre_num_offsets++; #endif return fre_num_offsets; @@ -536,7 +537,8 @@ output_sframe_row_entry (symbolS *fde_start_addr, fre_write_offsets++; #ifdef SFRAME_FRE_RA_TRACKING - if (sframe_fre->ra_loc == SFRAME_FRE_ELEM_LOC_STACK) + if (sframe_ra_tracking_p () + && sframe_fre->ra_loc == SFRAME_FRE_ELEM_LOC_STACK) { fre_offset_func_map[idx].out_func (sframe_fre->ra_offset); fre_write_offsets++; From patchwork Mon Jun 24 14:23:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92803 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 AAD3E386C599 for ; Tue, 25 Jun 2024 05:15:26 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 833B0386C584 for ; Tue, 25 Jun 2024 05:14:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 833B0386C584 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 833B0386C584 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719292495; cv=none; b=ZvpdGU/sTzWhxasPY/WUXIj2v8qLEtc/yIfjgHNgCFfl7X0JP+AQbTBnYKm4LNWLW/aErUuEuBTNcWam0ctuitA3Epw75sHVAmPsI3xotEx6eIsONpMwuCq57PA9xqS9EOY4Y8tu0S8advfaBxdaeUH3xqkct0JXovqukCHkiA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719292495; c=relaxed/simple; bh=t603pA9F6/AT0jv13/5w7kinjqyWgGZhf19PlIX8SIg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=scoqsbwW1IDGcunQ/S55cwiRaAqwkZEoJdl+CoRAT7elaiE1hMrDvPioDXxWKHdpHrwKht0w8mIQIaUDoZptWhUgABnMBoax2s205SLdrvQEbjHhv1VxQuhj9j82Ebq9YZmq/tiBrK9w1xNMOoI0FntQfUud5TWz459CNfPGA9A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45ODLkCe008276; Mon, 24 Jun 2024 14:27:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=EbAyxs7yY4emP mA0oPvl0rBFJe77X4P8MTkYR+mJvfE=; b=eUPUcdd0qFahGq6XD/ofdWDcjkQkb mDUBThL2FStpORkR5Do3XdNtxp02zqBnBFV+xmpZqEHfg+5huJOg0xd5trITYisv uJpSP4mxQS6iebbj5nLFdaoqvcEwkjGKbcsRp8l+y4Ident1Lv7X1NDW53wYYaFQ loSo5CPoJJaOueCOxDghdz4RFkBLwijvS3EW2sHZcWpOngQON0eNRvFjKm+AcwNG pxlV3nt3lr2kTdXpiyFn9CMKKeK4dvYUNJhXoo93rmOFNoqaFHza1/HNx7wk8y+y xyu97me+c3sR8lvhQdHGuVBI1oem+uhywZYZCj4mvyvdfaiQDycOv/ZeQ== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yy7ha8jcg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:27:47 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45OCIExb008184; Mon, 24 Jun 2024 14:23:45 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yx9b0hcx3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:44 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENdih19988888 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:41 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1E4E620076; Mon, 24 Jun 2024 14:23:39 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0733020075; Mon, 24 Jun 2024 14:23:39 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 15/15] gas: Validate SFrame RA tracking and fixed RA offset Date: Mon, 24 Jun 2024 16:23:34 +0200 Message-Id: <20240624142334.3283823-16-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fvbo8Ge7rFT_VTb6kI50J88jl9CFTXIM X-Proofpoint-ORIG-GUID: fvbo8Ge7rFT_VTb6kI50J88jl9CFTXIM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 impostorscore=0 priorityscore=1501 spamscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org Verify all architectures participating in SFrame generation do define the mandatory SFrame return address (RA) tracking predicate function sframe_ra_tracking_p. Do so by explicitly not testing for the macro SFRAME_FRE_RA_TRACKING as otherwise required. Verify that architectures not using SFrame RA tracking specify a valid fixed RA offset. gas/ * gen-sframe.c (output_sframe_internal): Validate SFrame RA tracking and fixed RA offset. Suggested-by: Indu Bhagat Signed-off-by: Jens Remus --- Notes (jremus): Changes v3 -> v4: - Implement review feedback and suggestions from Indu. Changes v2 -> v3: - New patch. This could be made dependent on ENABLE_CHECKING (configure option --enable-checking). gas/gen-sframe.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index f83a64518c28..626dc33b71dc 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -667,12 +667,16 @@ output_sframe_internal (void) -fno-omit-frame-pointer is used. */ out_one (fixed_fp_offset); - /* Offset for the return address from CFA is fixed for some ABIs - (e.g., AMD64), output a SFRAME_CFA_FIXED_RA_INVALID otherwise. */ -#ifdef sframe_ra_tracking_p + /* All ABIs participating in SFrame generation must define + sframe_ra_tracking_p. + When RA tracking (in FREs) is not needed (e.g., AMD64), SFrame assumes + the RA is going to be at a fixed offset from CFA. Check that the fixed RA + offset is appropriately defined in all cases. */ if (!sframe_ra_tracking_p ()) - fixed_ra_offset = sframe_cfa_ra_offset (); -#endif + { + fixed_ra_offset = sframe_cfa_ra_offset (); + gas_assert (fixed_ra_offset != SFRAME_CFA_FIXED_RA_INVALID); + } out_one (fixed_ra_offset); /* None of the AMD64, or AARCH64 ABIs need the auxiliary header.