From patchwork Fri Apr 12 14:47:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88435 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 1D0C73858408 for ; Fri, 12 Apr 2024 14:54:54 +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 B5084384B11C for ; Fri, 12 Apr 2024 14:47:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B5084384B11C 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 B5084384B11C 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=1712933259; cv=none; b=AoOTNLCeAvaHC3tuBHFm3CXdX5cdnLovqSpzUFD/MEgMvhE4Wy3AH6Rf5H1584DQMX68V9PZc6bJuNqL2Gy4mMuAGstNdMRyUJn79L75jEmgRmxzrKSti3X0Ot9DNSo95CaJYcj5uYC0lAS4UHafTjapvJktZwde0zYDPe0ciTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933259; c=relaxed/simple; bh=OZoUAu7X4i1cymD4W0H7oks/lGXoWjfd9yg5HvE+Ifo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=wDrfogjiMUAz0YIlUpMxoW30L3q2xcbGYkzpr4rC3ZlVoahA3cd0OFk/ypfXFpm9wscEnH3Rb9oFygaM1QquTKZ2tZpS5efaZShgqMaTN/d6v9T/MA3pA12mqEuemBdDxFJo1qvsqZ+4b5Cgpa0lvDYaJ9EzYR2xPOkcKgovqvw= 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.17.1.19/8.17.1.19) with ESMTP id 43CEfHjV013104; Fri, 12 Apr 2024 14:47:35 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=b6stuqM80AJdkc1wcT+BNtDapxZFM4yDRcDEFWN/epc=; b=QLAo/7fIZtc8yOy86+ivrcFNdgHlAXDXCK6M4vdwJRPd7qD2noYLWGlAF1C0CRpAbm84 YdtoCYlAIKogLfxdeBf7H6J3lODLM571DT8XjDpKNPdamhA45ib7FpkzRf207IizXq14 KVlF4vyPxL7bwEbrhFtCoGNp4XzwbzW3/AevuzZaPjTaTTuMwKuFi7IpaxH98IhoxqDk lMFKU8I3ODFAs/1Egmut9OUVFuCBAJqKIXLp0U7KUF08Y5M2S8oYdBYlodDEn5c2nGMI V4nUiiosXtv7YG3CMoQAzGlT8jaqqnVvBjvEjHArzE0bH/J6K/lLdW/sghZZqDIs/gwS 0w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xf5dg86ws-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:35 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 43CElYCY024344; Fri, 12 Apr 2024 14:47:34 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 3xf5dg86wm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:34 +0000 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 43CBQ13R029907; Fri, 12 Apr 2024 14:47:28 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xbj7mt9jh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:28 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElMs838666606 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:24 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8993920040; Fri, 12 Apr 2024 14:47:22 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 590952004E; Fri, 12 Apr 2024 14:47:22 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:22 +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 v3 01/15] x86: Remove unused SFrame CFI RA register variable Date: Fri, 12 Apr 2024 16:47:04 +0200 Message-Id: <20240412144718.4191286-2-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: qLQLvinyrAodNPaQrhxGnMplEuZPy-BW X-Proofpoint-ORIG-GUID: WqLAxJjmQh9-87z8TGHkj7tCW7-IHc7h X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 clxscore=1011 lowpriorityscore=0 suspectscore=0 spamscore=0 phishscore=0 impostorscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 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_H4, 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 8f6337b34af4..cd20e0c9415e 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -629,7 +629,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 Fri Apr 12 14:47:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88428 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 2B4F03849AD3 for ; Fri, 12 Apr 2024 14:49:54 +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 951DA3858420 for ; Fri, 12 Apr 2024 14:47:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 951DA3858420 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 951DA3858420 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=1712933268; cv=none; b=mVqI3o8VMZXuvQI12NVU3g53hjVB9HyCh1OJZ0fkOnWqxVtlCB1YLMtiADosJ9tqL+8W7269hZdSIXItpNPlHmFn2JcW9jjOOg0uZkmBGO5bNZXJCkoRA08+fwidOy1iYCwOkk6sVam9Osg3VVs/wAVmvL64nQ2z1xWy6DNbI3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933268; c=relaxed/simple; bh=yatUq0ki/+EG9dDV6DfNUECDF2Yiur08MA0jgi7LVsA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=jADB5MMMNDCcp9jQcVgAY2lDh1H2LpAoQCxxsNTJ7fAM0EiZ2GYi7p4tAg5r10qw1wP06siXfGkDprNnrXnWqu4pnCJVo2avfOoTSgTSVZLBoxDWC7MWGfmFINn4tGyXYv/bKdH/iVyUzHYuky4ArNjgXQNCPNIc+FXJHl542Sg= 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.17.1.19/8.17.1.19) with ESMTP id 43CEgWDn001794; Fri, 12 Apr 2024 14:47: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=mr9U5FKlHxdrtcMJVL8G8mJJY4/YkGVshkNC8nbztk4=; b=nydxSZFDJGKnOE6Wts4FT7gHIL49GmvMYnh6vbz9SUUScMqRpBEYSnC+xywhNtCTBYMA ycnGb/WVJyyqk/h7ZuUzdEG4GEUAAp0k8tIdt/1t2V6pBpHYp5BSrr2Ch0vvGRcmMnDA hCj6Q7Kb+2GmQWLNKhCsAp5ELhoA3TWWVr2hY88A+PQRgpVkzfTy+YHBCcLEeB0kosaG iBQJP6obFgi7PrAyWlJVzID2AqfgpiElDKTQt60yxhDyQHXNI2O0R1/AIsJePSEAIWov Y/NqL9NUzgUfz7/NPimsCKzVTA2/zuU9ttY5GvD0x3ru4eabGLiQUV2p+HYO4zDQB5lR ew== 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 3xf4pg8av6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:43 +0000 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 43CDwM9H022573; Fri, 12 Apr 2024 14:47:28 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xbhqpjdqu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:28 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElMTZ53019028 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:24 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB4B42004E; Fri, 12 Apr 2024 14:47:22 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8FC652004F; Fri, 12 Apr 2024 14:47:22 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:22 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 02/15] gas: Enhance arch-specific SFrame configuration descriptions Date: Fri, 12 Apr 2024 16:47:05 +0200 Message-Id: <20240412144718.4191286-3-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: jmX-MjV2iw1AxiSZGoIf9KJsy6VXuk2W X-Proofpoint-ORIG-GUID: jmX-MjV2iw1AxiSZGoIf9KJsy6VXuk2W X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 adultscore=0 suspectscore=0 clxscore=1015 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 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_H4, 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 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 6ad4fae8b0ec..077cbd485979 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -8870,7 +8870,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) @@ -8878,8 +8878,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..63acbd46a379 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 cd20e0c9415e..08a8eb2aeb69 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -11181,6 +11181,7 @@ x86_cleanup (void) subseg_set (seg, subseg); } +/* Whether SFrame stack trace info is supported. */ bool x86_support_sframe_p (void) { @@ -11188,6 +11189,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) { @@ -11197,6 +11199,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) { @@ -11204,6 +11208,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..e98362111698 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 Fri Apr 12 14:47:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88422 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 62AD23858417 for ; Fri, 12 Apr 2024 14:48:11 +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 C34793858D38 for ; Fri, 12 Apr 2024 14:47:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C34793858D38 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 C34793858D38 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=1712933253; cv=none; b=r+rE35muO98Ffa5c5ZnMknpU+48yVvHqwnXrzn0eov1BmhDWy09pToaAkNQQdG3Q1J9INXnVOKIsMHLueYD0zfOGekWEsbP7QqZSeDGYeBM6oYayvpJaWCrxLi2Wj8kEQ0lYEzRu10AKIn6i0RqIL/wvLJ+TOVCO0bknHqWB4BE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933253; c=relaxed/simple; bh=L3Cv2WjNxyllqVVYVBZOQq1Zse9HcaT4j10aGM5tIII=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=IZaZuSuzppz6FG/U0U67sd9L++MhlTMBUHMj77YjCYFgSwaO1TeeRGJ/i/NauugGwUOi1O3EWs/BdHbdeV3CufiJxSh1QAHiQMhXgQ2YqISnBR3BjrdEpVc5bWK5DJf2YycJYxNk2pvmHQ98Jn4dZPWgRoXw6KiWwkM+7YQo8l4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43CEfVhb004779; Fri, 12 Apr 2024 14:47:29 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=u+pXR52joeoRvkwJu0VUQsZUbPCGUWM22jKg7Bj19Dw=; b=tMjbWoSqKIjdV91aaEQ3K9WD7mApCfVl3B0yhMe9B+2LfUmQECDS4dwuVo5J/ml83l3V 1uoFkzEGbzNcOiE2kK9nS1aPBCE1KTS1rYidWe1xU4im41lugkYbUAoAkBDVv/UohzLC QB76xVKO+JrnvS0WAXGgCPgqbdzGc0OdjG+T7VzseoCZvPOWFEF5PR3SBdwcGPuHhg/Y BOavl5yAfqHReuIXo0bbrWS2kow/3pv2WDDen5vN7Br1UwYbYQ2UZ8e5F4CNb0i/4iy2 1+Hmt9QnjDGDANAHJ4aqlxsOrb5oDEaZRxjQr2G572DuHnQOLlCNJC4ZzHolIHupoY6L +A== 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 3xf5kc866g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:29 +0000 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 43CDnpI1019119; Fri, 12 Apr 2024 14:47:28 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xbh40tjta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:28 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElMAg50332138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:25 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D43CB2004F; Fri, 12 Apr 2024 14:47:22 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B17852005A; Fri, 12 Apr 2024 14:47:22 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:22 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 03/15] readelf/objdump: Dump SFrame CFA fixed FP and RA offsets Date: Fri, 12 Apr 2024 16:47:06 +0200 Message-Id: <20240412144718.4191286-4-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Zk9nAsIa_SXdZRxAU4lqVoszX17zzgAe X-Proofpoint-GUID: Zk9nAsIa_SXdZRxAU4lqVoszX17zzgAe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 bulkscore=0 spamscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, 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 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 5e734610b970..9d123a73826d 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 7f4db31fe1b7..ce5f94386ac2 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 Fri Apr 12 14:47:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88426 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 4B039385B50A for ; Fri, 12 Apr 2024 14:49:43 +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 D41053858CDB for ; Fri, 12 Apr 2024 14:47:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D41053858CDB 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 D41053858CDB 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=1712933255; cv=none; b=jz9AO80jQ9MYkY1Ot4pBxklpbj1MMTkjVcR7l10K0FzMaSAID0tQWcyAi/M1jt6RYbR60l3daK2HtZQXRRUnnFB1oXE3aEvLzN9J414/VJ1pfaLPdu2H/+PVuHS5zV61S46nw+TY0HG/CIxSsysxu42wLkyl0PCWm0D2xZsYs0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933255; c=relaxed/simple; bh=7aSXiX1Odf/ub2aGC+0MX3mD6ZbRo349XWFsKSKEg+k=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=rjzOlrHNKxsm3+nbodlfSzDHUfQD/Hi7/on+cojG8RgNJcnXgNCcIqhVbGPC5fi2lP8pi9cMhA0TDHzk0h7kbH8ndLLKPzBzzF3XQx+dW/TK8BPLZL9zMBurmRANEx+q9fpKQvxYyXcNTcP/f+tdDk1oQzn8oSzGLwo62TNTZeU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43CEfVWw004824; Fri, 12 Apr 2024 14:47:29 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=Uc8AbevMLxr6wKGNpBE6vBbSt3PX87BzqPFY36ySYBQ=; b=SctKtOw7qwVSEoF6Qc6ILZrHWAQkxQ/Pg3jJ4r2Ykb9jzUjHQMEvCF8HQYzA27DGSPB7 Z2K21J/IVF6u2hySQ68/qA1GOw9S3stzccZg6EseCoTIxbHxcbmvNZcpApgarVzE3Ah+ KiKsKrdMFMlmM0l1ejFOclZx91NgVUvFrjgSaV2dk4LiPwG3kV9zYRahqISDfyxluBfG GyA4IUTNJIByR50/+iTy7ukFCdOTNAtMCY/U1aCi69SxVctoIWEtdRlNySJS0DCq94td 2sU0KfCS2BP8cXe5Ap3XdywkbJ7WWUp0+d2ToCcCvn0UWISu1DFcBVZ0vWzqWge8leiV Ng== 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 3xf5kc866h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:29 +0000 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 43CCCWX7021556; Fri, 12 Apr 2024 14:47:28 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3xbjxma43d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:28 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElN1R50856268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:25 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 07F952005A; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D9C9420063; Fri, 12 Apr 2024 14:47:22 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:22 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 04/15] readelf/objdump: Display SFrame fixed RA offset as 'f' in dump Date: Fri, 12 Apr 2024 16:47:07 +0200 Message-Id: <20240412144718.4191286-5-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ZMT0-0NRPniYFSmPGrKWfp32go_LLmY- X-Proofpoint-GUID: ZMT0-0NRPniYFSmPGrKWfp32go_LLmY- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 bulkscore=0 spamscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, 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. 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 9d123a73826d..617fb9950acc 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 ce5f94386ac2..18c863938d39 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 Fri Apr 12 14:47:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88430 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 33D61384AB5C for ; Fri, 12 Apr 2024 14:50:56 +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 81B173858C50 for ; Fri, 12 Apr 2024 14:47:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 81B173858C50 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 81B173858C50 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=1712933255; cv=none; b=w8qPdqdtNqdF+wOX6kJCR8JP3ZSCzOobs8WvM7gurzhMPh3B5x2d5rMcBxM3u/CEUaMAT2FiLEJbbnk6fHIX3mwRScSOB+cFWYWkQL4wc5bNE2YQ9mgIuZafdHrHCJ1+KqtwtYKiAgkCIAQL9HCJeNkxQU699zDn0niXkZYi0yk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933255; c=relaxed/simple; bh=R8tm5kPtP88dlvqlSHSR135orXYfWI3kV2Due4OlEgw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=VbP62uSlhk4BJGQ1uopUqPIhQf0a+ktNkCxsDfBHBAgQ2kgbJTH88RqpCQYRLKnaiN6D5pRN568ErBbbNfK8shfUH3IShyPDCfi5zOXfxsBmuOVZznmB9TZhWVzU0RZoMlTWuX26GNZ/KkydfVbp/Wa6lp+1ZnqISYFpI+0+eMc= 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.17.1.19/8.17.1.19) with ESMTP id 43CEfNeJ016056; Fri, 12 Apr 2024 14:47:30 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=godk6a/Vhi4HVHtQLFKW8lR5qf9gJLXnaVBfeUAdvKc=; b=J4W29+pkjmVVgBD0dGrVcHcLL6Gv7JPpyU7djUeiGuvfnSwsF0Sr9cCcMxySW55iIQ/J 0h5K6F+0F7EMy8cG5QwhgSXy+3Sd+NQ/+v3ffM8oC35uaA+hqgFeReXiqmRdb2XIYUA1 YSwEXd3m7CrtVhqzwnqU+KRq9fzA0SgWrErfxsG7crDeB5v/UnTWio3DCUuQj692wJEv cZCF4gnNBXMQbJeD7xOTa6Gx4ubZ5iRTqOKa0Dw9SlLj9cne9G+lWQrYKbAnoO5m2T+b QQrBOXVYeNmoYUhY8TCsIhBsL+gmUzL9vRYouOGp10QeBPGdj1wuhSCBEm82km4CweEX mg== 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 3xf6qv8176-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:30 +0000 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 43CBQ13S029907; Fri, 12 Apr 2024 14:47:28 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xbj7mt9jk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:28 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElNTh49676606 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:25 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2921C20063; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E07C20067; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 05/15] gas: Print DWARF call frame insn name in SFrame warning message Date: Fri, 12 Apr 2024 16:47:08 +0200 Message-Id: <20240412144718.4191286-6-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: urUQEJSNuRYPUn4F46YcZVSBF2SdX05_ X-Proofpoint-GUID: urUQEJSNuRYPUn4F46YcZVSBF2SdX05_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, 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. 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 due to DWARF CFI op (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 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 75781fc8ccbd..d35baaac54b2 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1197,6 +1197,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. @@ -1272,7 +1312,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 due to DWARF CFI op %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..d7756302b559 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 due to DWARF CFI op 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..20282c7854e8 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 due to DWARF CFI op DW_CFA_def_cfa_offset \(0xe\) #objdump: --sframe=.sframe #name: SFrame supports only FP/SP based CFA #... From patchwork Fri Apr 12 14:47:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88427 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 D46EB3849AC7 for ; Fri, 12 Apr 2024 14:49:53 +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 C891E3858C78 for ; Fri, 12 Apr 2024 14:47:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C891E3858C78 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 C891E3858C78 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=1712933255; cv=none; b=VAHm2wrkN/gumP+VVZ2A5Kpe6iCgU5H0DdJIAn0dCehOi1SF4kMoBK1BmlNo/3zeF+Bt4pyP1WK2difxqg+HUYlBSqCsfQJOusZybWU3fI/iSeowrV77Cm3nEgjW013Q9ug8O3j6raZzvfSMJPYrcQ/5cH0/SnJOtuInbLdlOig= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933255; c=relaxed/simple; bh=4WdPJ12CZGmSO9gwbGZPL76VsUhpFHMKh4DksUeReD0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=T1wlo0TprbBglQCAXOy60NT1As3yC45nY7rAvS074PCGWSWzv0umErnOMwnVaBrqs3+tw0jO5ME5y7CYBE5MWMyt5NnUOumj4kQJxlPk7TydLOG1Ak3fJCvXs3TGrX10zRKfjrYdm/DYBZ1PFlHNKjmREFA+pJuYytmYH8VI/tQ= 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.17.1.19/8.17.1.19) with ESMTP id 43CEfQ0n021150; Fri, 12 Apr 2024 14:47:30 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=HUR8pba8VBc1mhciTClcq/PcJdLVz+yGgNaKBzkO1B0=; b=pBjDN44Hc3qvRQ61BELnhmljfmyoh5u5rHt2Mn/n3ALe4ah37BkwCdal0a4ND7QxYQPg eklBLHSKJ8995KV6JLK+sX+GT+mWmyedDYHOBAxjDGd7thAOtcfL7ZZBcriOyKT2rPeM YFPtmQ01JufirPQ81x/UgpznwX2MKPZT3DYGdh8LgbDyRP2+R8yqYqoBBTqeeMv50lst x8gWi7x1SxG2FhGwPYewxW1MaPTY4XKr4yWx4tpfoIpIYZgwgHMmT04KEx/Fmq3FgRSP Vw5lHj/t12XlYcQoWHhPpB+4NejptVGDfcgIlucWEi6OnHyJPCS93o0WbxxhVkRR1di4 xA== 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 3xf5ej07fs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:29 +0000 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 43CCf2OU017031; Fri, 12 Apr 2024 14:47:28 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3xbke32002-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:28 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElNle49152418 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:25 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4963420067; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2EDBD2006A; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 06/15] gas: Skip SFrame FDE if CFI specifies non-FP/SP base register Date: Fri, 12 Apr 2024 16:47:09 +0200 Message-Id: <20240412144718.4191286-7-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: lP6KU666fS5f8wGjI6fGmOY3RTSVpfKR X-Proofpoint-ORIG-GUID: lP6KU666fS5f8wGjI6fGmOY3RTSVpfKR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 adultscore=0 clxscore=1015 mlxscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 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_H4, 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 d35baaac54b2..1269b2b77c54 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -986,7 +986,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; @@ -1004,9 +1008,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 Fri Apr 12 14:47:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88424 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 85593386101F for ; Fri, 12 Apr 2024 14:48:26 +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 9B9233858C66 for ; Fri, 12 Apr 2024 14:47:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9B9233858C66 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 9B9233858C66 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=1712933255; cv=none; b=xxV6JqZ8TFFHJoSxuzW0Tp0fY+wUR0N7kTK3FfjogVwFnSnWD6+Tg8vj3NPIsf+wBAQAErtqRzqIFAtUnfEDo62VsUvmygUzZ9XrE0cYyoUrkRQZUvp/UhNsKfY3fDAYvJH8lk+4QzwvJd6epQ6r+E1tMLAcsO1dTMvEoxp5804= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933255; c=relaxed/simple; bh=RjYZEZB+Wexd8mUJe6nGj4Uys0/k+VcvUkT2JaZlbWM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=WPLzpJ8JAnZRmnT8o9JWDCdgyLBD7rWm7vUY4d7teRl/P9VDrhRO0XD4JqdvD/9IWEv706p1YFgZ+hTYRF8AlSwfKAK6OSMb7bOY55vmnqXhzDLDzFxuNs2dNUlfvFm/vEAAkI35nmBb1DB7/5UrwCLHGIPPdBHK7D0/zN/yByw= 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.17.1.19/8.17.1.19) with ESMTP id 43CEfZx7021459; Fri, 12 Apr 2024 14:47:30 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=oEn7a/tyFVfJBxdp/Jc3c0JL0ICGtr+lu2qJJPm14wI=; b=OmtNTB0u++v54QtMfIsfNmtV4i34Km/XgEN8/bvowXdq/h9806VXkIHSMpZE8+oPCYbA HVpeQEpZ8w4UsCkF7NUP2t5Lt7BiYjlO1EqoNCTkXc+Pp5j1FcvJAxqcYHtn2uPslcHS Epde42tsFKrSA75nKcITiHvZNe92XhCdv+bShMu4VH2xJQxGpd7gqopnP2vqbZPiOy6o EDKeTLjKokjTZ1vtgcNeSFKFTo9IZOe4Lv9q6bBYdsPNtCoFSMsbFMoJrPqIfuJYWQUD i9jgko8JPcS0TkZ3W79HMULbFUgD+LmVmm+m5T5pKyq6IIOqqjl8ldWftP9T0ng+8AHo uQ== 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 3xf5ej07ft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:30 +0000 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 43CDgCfv019092; Fri, 12 Apr 2024 14:47:29 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xbh40tjtc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:29 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElNo552560306 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:25 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A5D52006A; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4F5522006B; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 07/15] gas: Warn if SFrame FDE is skipped due to non-default return column Date: Fri, 12 Apr 2024 16:47:10 +0200 Message-Id: <20240412144718.4191286-8-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5ezL_CchvjXNuhdnJA52J26KoeQer-wB X-Proofpoint-ORIG-GUID: 5ezL_CchvjXNuhdnJA52J26KoeQer-wB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 adultscore=0 clxscore=1015 mlxscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, 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 1269b2b77c54..fe8b24906c1b 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1343,9 +1343,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) @@ -1355,7 +1358,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 Fri Apr 12 14:47:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88436 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 347C63858429 for ; Fri, 12 Apr 2024 14:55: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 B85FA3858288 for ; Fri, 12 Apr 2024 14:47:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B85FA3858288 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 B85FA3858288 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=1712933267; cv=none; b=BYWKwr6016Y9e9MSldk0zYZpGPdb/Qv0gsyAsrgxcyegqwqAirIacSTkwUxxlxDRnW6osho8oz52Pp35Yx9PDPUIQ1W+wRZQ28Pfn3f9x+9WksH778ofYxbIcBqzvRF+cDg7O47v7pXvEPXeujTv69feobMUxTsIzoak9GUA+yA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933267; c=relaxed/simple; bh=wajf1fRKEUXHkR2SZeLcrIKO1/4+mU6nTm8XTS5Xbss=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=oRdNf5OIdfe8eg8AS0VmcfGzlSLpb896UnjckKMKmYnfUMQV1QJoLyJilNf3U5vejIuE3qxAUTcibfFXQ2u28LxYRWTp3UziI5CSl1Xot/iypRfci/W92zWzGKHwClfjHlf51OwhJrxewPzHiwIc7GW3JwGYnyvM63QLKIdahSw= 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.17.1.19/8.17.1.19) with ESMTP id 43CEgBOd001378; Fri, 12 Apr 2024 14:47: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=dnmV+nnsBuFUeqyMU0zeZZrZ1eZkvWTjnj4+bxnTUuM=; b=VHZ3BSmAh5p49mfG1MOBmfHhkxxSKKi4jtqSIfwQQoVXcieFwI7DZe+mu2aI1sgcSxnx 25vN0A6qzmc+r632JixC3qN8aOF5BZqFz6xEEg55uzEfP9EXCTiLLqZJa4yV6M+QJuek t6NfrlYt0vtgERPXNiVv8hr7pw72/eKLvpZKyhMC9CFMosdPb6Dm5o7uVkb+KNsAveA+ bG54hW35gMQYE7m54CSGcl52AbNjj4qWCxQD9mHeyDs9LFZOvjf/MqzDZ9oMl/37xFRx 1KL3QXcqCcGAU1ngCOsEU3gW1f3oHSf81M3g5S/GVWZ3Lij88XLtlfDl7i3Qiaoo234p KA== 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 3xf4pg8av8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:43 +0000 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 43CCW46B017280; Fri, 12 Apr 2024 14:47:28 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3xbke32003-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:28 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElN4329950324 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:25 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8AD292006B; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FCEE2006C; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 08/15] gas: Refactor SFrame CFI opcode DW_CFA_register processing Date: Fri, 12 Apr 2024 16:47:11 +0200 Message-Id: <20240412144718.4191286-9-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: yiBFOhFS-1T0Bh9ep8rR1q4c8qkD4XcQ X-Proofpoint-ORIG-GUID: yiBFOhFS-1T0Bh9ep8rR1q4c8qkD4XcQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 adultscore=0 suspectscore=0 clxscore=1015 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 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_H4, 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. 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 fe8b24906c1b..f47f51c7a354 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1108,6 +1108,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. */ @@ -1296,19 +1318,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 Fri Apr 12 14:47:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88433 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 A7FB0385841F for ; Fri, 12 Apr 2024 14:52:57 +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 68B793858403 for ; Fri, 12 Apr 2024 14:47:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 68B793858403 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 68B793858403 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=1712933257; cv=none; b=clwu7RQR1oeU/XDcJSgkUv0bjWNJlSa1RQE7U03KHiV6BpRs1d+zCsBAnm+fBFr2IdIUiS6TyioG/PfoQoLL42SZ+vpV2x/LLV7gjSSV1d06rYDXAz74wSt4JntLyiJmPcWZL6ak8bENYAF88IpH1PX6Uv2P/9cduKN0PMqyUcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933257; c=relaxed/simple; bh=f/X+XaT/hyAABFh/Gb/TYh6iHx3C0hJI039c734njFo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=IqI3q0XrNCVRmGRPVy8jgBP6mG2bmK1Xe8kel8EajEeKgBRb48z+or2lD+YtfKJeMRs9/amvcSYyBPanrnoOJDn+G/5qGrtpZq7ENfTtwRmKsFkOthHkXX6bpFjSg7IBT4WZWUXOMlEf34H4bsVM/GA2vOxuZkZdkhl+SkokZmI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43CEfV3n004793; Fri, 12 Apr 2024 14:47:32 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=26j7+CjNCssOVyEYdHdBwZ3H7e0YL2zYl0YUNlCbxYQ=; b=JKrbtZogY4xnYQ2f81Mqa6tW/Ts/dTjaK2JKp0y4yZxc3X+RbJfEoXCaEaRcBdHmER4R GkRhqZFv5SCXEjpqqCmvqgPALeymO0Z2bLzIBNYa5RthQ5cnO9Ct4TTkn/BkWh3lgynA i6F/uvOOYoxvLIyq5B1mT38z01D1zIPBSudCR65NEfkADqxphb1LnP2bGnSP55vxPDZU dRdXY8pgqX5rrB8FAhElvx7RZPKVWFOczs7pvYhQckeBSKeTySdk9rr5kBtxZx2wJ0uu ROggPHOdg1X8tNbj7eIDTSZP/MOrc7sESn9PDmty06howbMZ9UDRPGD88WiTYGMGPIos mw== 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 3xf5kc866m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:31 +0000 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 43CCokaO016971; Fri, 12 Apr 2024 14:47:30 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3xbke32006-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:30 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElPW943516214 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:27 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B31B92006C; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 90C452006E; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 09/15] gas: User readable warnings if SFrame FDE is not generated Date: Fri, 12 Apr 2024 16:47:12 +0200 Message-Id: <20240412144718.4191286-10-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: HLHT1vgGpFMYyI0-s8jHe8oWvBucQ5Ub X-Proofpoint-GUID: HLHT1vgGpFMYyI0-s8jHe8oWvBucQ5Ub X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 bulkscore=0 spamscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 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_H4, 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 due to DWARF CFI op (0x) Whenever possible print meaningful warning messages, when the assembler skips generation of SFrame FDE: - skipping SFrame FDE due to .cfi_def_cfa defining non-SP/FP register as CFA base register - skipping SFrame FDE due to .cfi_def_cfa_register defining non-SP/FP register as CFA base register - skipping SFrame FDE due to .cfi_def_cfa_offset without CFA base register in effect - skipping SFrame FDE due to .cfi_def_cfa_offset with non-SP/FP register as CFA base register in effect - skipping SFrame FDE due to .cfi_val_offset specifying {FP|RA} register - skipping SFrame FDE due to .cfi_remember_state without SFrame FRE state - skipping SFrame FDE due to .cfi_register specifying {SP|FP|RA} register - skipping SFrame FDE due to non-default return-address 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 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 | 95 ++++++++++++++----- 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, 75 insertions(+), 28 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index f47f51c7a354..a3b6f75cfe85 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -867,7 +867,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. */ @@ -922,6 +922,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. */ @@ -990,7 +1007,12 @@ 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 due to .cfi_def_cfa defining " + "non-SP/FP register %u as CFA base 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, cfi_insn->u.ri.offset); cur_fre->merge_candidate = false; @@ -1015,7 +1037,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 due to .cfi_def_cfa_register defining " + "non-SP/FP register %u as CFA base 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; @@ -1046,7 +1073,16 @@ sframe_xlate_do_def_cfa_offset (struct sframe_xlate_ctx *xlate_ctx, cur_fre->merge_candidate = false; } else - return SFRAME_XLATE_ERR_NOTREPRESENTED; + { + if (cur_fre->cfa_base_reg == SFRAME_FRE_BASE_REG_INVAL) + as_warn (_("skipping SFrame FDE due to .cfi_def_cfa_offset without " + "CFA base register in effect")); + else + as_warn (_("skipping SFrame FDE due to .cfi_def_cfa_offset with " + "non-SP/FP register %u as CFA base register in effect"), + cur_fre->cfa_base_reg); + return SFRAME_XLATE_ERR_NOTREPRESENTED; + } return SFRAME_XLATE_OK; } @@ -1096,13 +1132,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 due to .cfi_val_offset specifying %s register"), + sframe_register_name (cfi_insn->u.r)); + return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ + } /* Safe to skip. */ return SFRAME_XLATE_OK; @@ -1124,7 +1163,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 due to .cfi_register specifying %s register"), + sframe_register_name (cfi_insn->u.rr.reg1)); + return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ + } /* Safe to skip. */ return SFRAME_XLATE_OK; @@ -1142,7 +1185,10 @@ 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 due to .cfi_remember_state without SFrame FRE state")); + return SFRAME_XLATE_ERR_INVAL; + } if (!xlate_ctx->remember_fre) xlate_ctx->remember_fre = sframe_row_entry_new (); @@ -1330,21 +1376,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 due to DWARF CFI op %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 due to DWARF CFI op %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; } @@ -1361,7 +1405,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 due to non-default return-address 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 d7756302b559..08731b069229 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 DW_CFA_remember_state \(0xa\) +#warning: skipping SFrame FDE due to \.cfi_remember_state without 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 20282c7854e8..e759cddfcc20 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 DW_CFA_def_cfa_offset \(0xe\) +#warning: skipping SFrame FDE due to \.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..5cc37d5ff440 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 due to non-default return-address register 0 #objdump: --sframe=.sframe #name: SFrame supports only default return column #... From patchwork Fri Apr 12 14:47:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88434 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 7F2C93858427 for ; Fri, 12 Apr 2024 14:54: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 1870D385840E for ; Fri, 12 Apr 2024 14:47:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1870D385840E 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 1870D385840E 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=1712933259; cv=none; b=m0zU0JWVRX+LKTqavWL/DY2jo2bt69XmFaAUgbVTPlTKUG/ivb8JXl5YNBs4fPimVSnPyz0wZrACyIVB0nYt34JHhZ0IXJ2j8jgXrDFbLVo/kEB2weOJ3iPAR7U1ORJYbKOI+7jFY7bs/WclUaMZXScM7PFEhuIjPRwJoxSjowA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933259; c=relaxed/simple; bh=UGWh40aP9zS88JEZUoiz/0pMczrIzdZ2iYpg1B+OygI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=hp/Cdv+LiHX2KvKk2j55s4qjNsy9F6a+fLuwyMdPXY5By+i7KbASg21O/b+OxYuGd8CBW2OnGCaPfoUhLk3SIOsE63enVFRY/vlaOsCHhEQdOv7VVPlu0JKE0z3DceVHT22jCYoo1EzHv8PFuEy18U95S33qlvIqk51BPdydxFg= 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.17.1.19/8.17.1.19) with ESMTP id 43CEfNZs016039; Fri, 12 Apr 2024 14:47:32 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=WErFI4gn5xD9oQ03vgJviG+xeH5nzvQdCbeV6hY9Nlc=; b=qip1A+bhPjvNMxGWGTktSY68x6OHY0FKifNkJRcCzfvH0B0Ukak/TcaH6rN2B4zUUIYt OzR0RgGsfSdrZdBGHCAV2vH5m1OK2ieocXK/WZJN1/5ZTVyNSWHKOuCJ4WaboOeJwjQT QT8qIjpc/9WJCGrrNLShUgQKJeoBOI0Qxtc6+TbAksOVfeU0HnZNNnGQiAJUYb1Hbctz GIO++HJhwSTBWsiVPuAESbFky0Q5Un/3YjZ3RM8hU0pMrWbVhQk1v7NerFOXn5A9y5Ox LnlPWCzq9N03eBH99nkr7yQbQHPnpnJbgbY3vjLjhlM1rtN0cQ1BC5mE7oFYM2kUvzwP XA== 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 3xf6qv8178-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:31 +0000 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 43CDuxm1019082; Fri, 12 Apr 2024 14:47:30 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xbh40tjtj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:30 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElPFk50856270 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:27 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D39572006E; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B88B02006F; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 10/15] gas: Skip SFrame FDE if FP without RA on stack Date: Fri, 12 Apr 2024 16:47:13 +0200 Message-Id: <20240412144718.4191286-11-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: cvAggVfwezjJi4AUDadOjfNlya-VwtN- X-Proofpoint-GUID: cvAggVfwezjJi4AUDadOjfNlya-VwtN- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 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_H4, 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 due to 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. Signed-off-by: Jens Remus --- Notes (jremus): 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 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index a3b6f75cfe85..87be3eb05ad2 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1439,6 +1439,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 due to FP without RA on stack")); + return SFRAME_XLATE_ERR_NOTREPRESENTED; + } + } + } +#endif /* SFRAME_FRE_RA_TRACKING */ + return SFRAME_XLATE_OK; } From patchwork Fri Apr 12 14:47:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88432 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 B6A2E385841F for ; Fri, 12 Apr 2024 14:52: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 4BC7A3858C31 for ; Fri, 12 Apr 2024 14:47:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4BC7A3858C31 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 4BC7A3858C31 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=1712933257; cv=none; b=GvYgRh7MmPUvKYpc7fnHDJlXMr7/JGNvK7pOOgNrefkCTkCZN9yrJV2zlGpzRTSElkY09vtWicaTXdwAv4fUm61u+oP2vLDk15Vc52Wky0KtqjqgweFsQvTz0rzBRgXKCIygPz8ZJgOsKIf3xVEe1Ak6WONpr6FJJT88s9snhs0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933257; c=relaxed/simple; bh=d6d5Oq7w9Sx0K4ULdZcAYnLIG9IdyYjeBR3BVu8lzRI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ZtfIgpvWHgU8JNl0ee4Yv4kwyGzvLz9pSTbhmi1YW6q3dAFT0qKsZwhi4DGUtynweqnzliNTfXrfRd5dxHN8BrwXWPgwX8eVF3nhQyUmveaa0z2rBmnq5fkrqDo+ot+JnEi1KgMkGB/RDcnEEqxGl5PGEAMnin0TzDtaMeOoO3c= 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.17.1.19/8.17.1.19) with ESMTP id 43CEfYPO016344; Fri, 12 Apr 2024 14:47:30 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=lVUa3QXFPQXZ37KB0HbkKUOfYXZbiCfik84bsUay01A=; b=s0ZAOKue2AWhpJG1m7mJbbbms13z8MceQHm/V99KUrXAl9oL33g5Na/Jxb2dAtzV2EwX IXLE9AHhpP/2jg4sV8F+bTiNR8B7WbgOePAueGLjkWC2bm6p7GWArRH9YWF4n7zkLgQj 0pv+o9DnErtBKWhBW9hTpC2YVAt/YHBhyYK+UltiZkrSPpTs72VcoqpWFyrOI42VUFVC VWfOb4lGQ7ei0CmoASKo2McJrRXYrvvpws61KIOSXxCTRC7BRuJSs0mE/OrCzF2VhpuX TnxfYh8nB8QWfyhoi/5sAm0fDxeAN7yZmyTqCTkaSyshnwy+chOTe+TgnVk+zmL5hIDP Pg== 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 3xf6qv8177-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:30 +0000 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 43CDoF8E013590; Fri, 12 Apr 2024 14:47:29 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3xbgqu2nft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:29 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElOr647317358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:26 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 002F02006F; Fri, 12 Apr 2024 14:47:24 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D944320070; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 11/15] gas: Skip SFrame FDE if .cfi_window_save Date: Fri, 12 Apr 2024 16:47:14 +0200 Message-Id: <20240412144718.4191286-12-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 6xfr6Wi-NGhbdnZWEbTQw_Db-SGkb_bT X-Proofpoint-GUID: 6xfr6Wi-NGhbdnZWEbTQw_Db-SGkb_bT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 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_H4, 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. gas/ * gen-sframe.c: Skip SFrame FDE if .cfi_window_save. Signed-off-by: Jens Remus --- Notes (jremus): 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 87be3eb05ad2..98166de8cc01 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1257,12 +1257,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; @@ -1274,6 +1274,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 due to .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 Fri Apr 12 14:47:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88425 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 C1699384AB5F for ; Fri, 12 Apr 2024 14:49:42 +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 DB7A83858C33 for ; Fri, 12 Apr 2024 14:47:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB7A83858C33 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 DB7A83858C33 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=1712933256; cv=none; b=FxGViexR2KMqoaxrNoU3Zrhc5g5aT/gVVo/fJ0rRf3usjHS1/OvbFqaodWgyPOle5uWXREH0ZDB1I0iTlbTzks7mWex6uCo7IHtP0O6+DwaDnyYGfambBIVJMp1dhNNC3VnUkZVZFXy6FSI9HXor0tn0F4bYfC9Db7zN2gOuh3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933256; c=relaxed/simple; bh=eLEZW7tTFmOxYygmHCljoZjJbqzcxuYDAFaYJvTnTAI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Rh7vCdbGPxdTE5ZoQwx5RmODzyky3ZepmtU5TAXd1/Nd37w19E0T0s+L7C7gzgBgAU9lpAwHupQAJQ3i/+0Rooco1HLGcZICi9Mlh6CiN2IDj3WzJuPhe1H4i9B6jGo0rAgo40K+q7TzaUlodTm0U9GAPVKcbLHdkXp1C+qDiYM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43CEfpYG022962; Fri, 12 Apr 2024 14:47:32 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=z1dSKVSy8HEg7AJFWRPhPMqjVqd/tPZSpcQeGEeYqYM=; b=bLNYs9kfMbTX/Zkn3NczhDrBed4x28LA1aieTg2BuoY22Ed1CYUyQID3T6hX0Z0Uce8p eMU4pT+9mQGFmgAUug3r2iUHnrvKfg3Zcz3zgEDAuEs4jCOR+5fQmfd+pNTsB62pUCBQ FJn+NfjQaTD9c/layfVLVAXX59lji/qLIPuh71wyHFNSknTW2CrCpM9DzFycTb+Xvqg7 7ZVCHcHO1DVaHHdyxjfyty0Z5hpB8j9P06nSOnfhWzaLanGVChGpoAxv56BZVxl1Ve6v c5DqIXqkGO9Xr0CLuZ5uJ6/DhMJuMDoABVf3poxyMQL70sS8R/kKDU8wqT7lwoKwSRt6 7Q== 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 3xf5gug6wa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:32 +0000 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 43CDuxm0019082; Fri, 12 Apr 2024 14:47:29 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xbh40tjte-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:29 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElOrJ28770734 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:26 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A65620070; Fri, 12 Apr 2024 14:47:24 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 058BE20043; Fri, 12 Apr 2024 14:47:24 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:23 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 12/15] gas: Don't skip SFrame FDE if .cfi_register specifies RA w/o tracking Date: Fri, 12 Apr 2024 16:47:15 +0200 Message-Id: <20240412144718.4191286-13-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: YO_783Jt8AiUEynDxnxjrkfeZGMUYO7l X-Proofpoint-ORIG-GUID: YO_783Jt8AiUEynDxnxjrkfeZGMUYO7l X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 adultscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 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_H4, 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. 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 98166de8cc01..61c846f214ee 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1160,7 +1160,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 Fri Apr 12 14:47:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88429 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 E490F384AB51 for ; Fri, 12 Apr 2024 14:50: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 236FC3858C39 for ; Fri, 12 Apr 2024 14:47:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 236FC3858C39 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 236FC3858C39 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=1712933257; cv=none; b=nc/VwWyIX1fDnEeLZtHKl4MV0YmR/dWAsvuRbT1c1voAGYzQhpjfoIl1DrJYCgIFJKc2mqiTFFGGjfU10TTCY3ityrZL0oscdfiQSaejsggXaZaefMHIDpz0ueXNg1LOfnR0gVPuXOm8fEWmUu4QY0E++FktTJTr3eMP7yDbQJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933257; c=relaxed/simple; bh=GXOBR1G4QE5Do57Ip0uYwWb+KWycAV2GRpcOdP3RSfA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=IPoUdsnWo8u8FQHi+2a7iNWQmjy6PBoJHWm2BYMH/+8Hc74LPGVbvCVF0fmG631uNTFNogviaGfMphFDXi2fXxgYyfH4eeRWU0hY/fvdjdNs6y9yJraK5C5MqJ0vRb5smCTsrojhwZpNMNhnA7oGoYLWkBtfrRhQJi0hvOPwUi4= 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.17.1.19/8.17.1.19) with ESMTP id 43CEfUbE023377; Fri, 12 Apr 2024 14:47:30 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=yoO5EGztLEDamYVnzJP5byNMqM41XpfhwkRacz3qc04=; b=XRnb5CPzLP8i58v1lO4evgiRoIZkQPWaBpZ0pdvsMIBDHc3tj68Uhm+QK2Xv5Sd4l6q0 2Zb1eyhPP6gEp70NzWDzifow2pmRYdjzzQqewSwLoNaQiaZyRJHv1e930+yQGjwcN4va KibyRzM5GocWJsMdA+r2iHezHRkP4Q6a+RRdD5nv7WIG3vjO1wvZALHCbS6CyCJ0jLA1 bxka6IZKaySFeS46b1r/qltNb4Ak9gkcEnxsMtsIO7A1fLoII610Pg7dSK5DANfvMsb1 1XjcUW8ex6wDBl7qkl0HNri34v9T+5XiLlDXrAljb+aeVBF2S0GeNSzVwzZ3KnNgVPf6 Eg== 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 3xf55y08sm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:30 +0000 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 43CD0H2n013760; Fri, 12 Apr 2024 14:47:29 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3xbgqu2nfu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:29 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElOHA29884898 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:26 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B1A420043; Fri, 12 Apr 2024 14:47:24 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2FD7420071; Fri, 12 Apr 2024 14:47:24 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:24 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 13/15] gas: Don't skip SFrame FDE if .cfi_register specifies SP register Date: Fri, 12 Apr 2024 16:47:16 +0200 Message-Id: <20240412144718.4191286-14-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Yy6rtLJsR5G0uBoFBZaGIDH2iOSnl-77 X-Proofpoint-ORIG-GUID: Yy6rtLJsR5G0uBoFBZaGIDH2iOSnl-77 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 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_H4, 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 stack-pointer (SP) register contents on entry can be reconstructed from the CFA base register tracking information from the current SFrame FRE and initial FRE from the FDE: 1. Compute CFA from the current CFA base register (SP or FP) and CFA offset from the SFrame CFA base register 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 a comment to the processing of .cfi_val_offset that the SP can be reconstructed from the CFA base register tracking information. gas/ * gen-sframe.c (sframe_xlate_do_register): Do not skip SFrame FDE if .cfi_register specifies SP register. (sframe_xlate_do_val_offset): Add comment that this is likewise. Signed-off-by: Jens Remus --- Notes (jremus): Changes v2 -> v3: - New patch. gas/gen-sframe.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 61c846f214ee..12b523a8d59a 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1136,6 +1136,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 due to .cfi_val_offset specifying %s register"), @@ -1155,14 +1156,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 due to .cfi_register specifying %s register"), sframe_register_name (cfi_insn->u.rr.reg1)); From patchwork Fri Apr 12 14:47:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88423 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 19E303857C4F for ; Fri, 12 Apr 2024 14:48:12 +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 87AB53858C56 for ; Fri, 12 Apr 2024 14:47:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 87AB53858C56 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 87AB53858C56 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=1712933255; cv=none; b=S+AE1l0bT0XdUiIYfgvPYMp7E+pMnMfri9X3Vu7g6VOqy2RQQCvOZP24DJMY44cUs9OABopmRZbk9T+ieyncfjt9lpM1ag46OSjJ9Q9vySuHg7/d4xR1KMlSFeo9mPoB7rsx0lLK95dqDa1j19GflWmlGWuGHDt+2E/aHHXhnys= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933255; c=relaxed/simple; bh=wBsoHn90nP94QT5i+KKisr6yfeELEM/jaCIeAOoemBA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=KnPmUZ8VtAJMOe2fvZZ5Ong0IqBPkDSfGcW0dKgEkGaPtyWnzT9TRc9HGQTq0gjqANlzqQSO0Gtga7oFJWqIGY7U9W1O4VHt0U9zaDxmD/lq3pGUd2/L9dyTIZHGjXAmt8KLdJ0pnlnu+Ys2J7ZojZBelLbZWjXcsF6GcvYiAXI= 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.17.1.19/8.17.1.19) with ESMTP id 43CEfYxJ002170; Fri, 12 Apr 2024 14:47:31 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=CQw+xDl1MZVZHasfkzX7+tRRWTg4dt63gf/AsuGSN/Y=; b=MTvyA/wZZOxf9LzAq4bT4+OqEBrINP/Z7R28GmLMLq7PPLYeZaaAeznAOJ4CziieyPbm QfkAtHKFxOLhjgq7X4c879b/33AHJwsGPFEUUlgaJSX2YX940tGaRZ69ykOjFb+USkqC psZaWaaIDoIxhGf+eAKVdTirqjDp66y7MDoGS1pdPwQafbXypCj2Qh/cDoeNBP6739KM wj8sh/jrwtb9ZHBN0dc/gImk2ZwM4LSc8gUqx9M1qoG/sy7xdnA4FouEEopC2nJ2ihPx EbBLwRHQHsyBiY8dMij7V63B+5xz5FNrwxN0bSskdP74PLXleU5i0h3Jr1ST2HS7AbHA 1A== 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 3xf5bug828-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:30 +0000 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 43CDgCfw019092; Fri, 12 Apr 2024 14:47:30 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xbh40tjtg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:29 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElOpG33358102 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:26 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6BD0720071; Fri, 12 Apr 2024 14:47:24 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 50CB820072; Fri, 12 Apr 2024 14:47:24 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:24 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 14/15] gas: Test predicate whether SFrame RA tracking is used Date: Fri, 12 Apr 2024 16:47:17 +0200 Message-Id: <20240412144718.4191286-15-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ochUT9NYEvooI4qmu1ZCZGuo0vQQy--Z X-Proofpoint-ORIG-GUID: ochUT9NYEvooI4qmu1ZCZGuo0vQQy--Z X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 adultscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, 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. 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 12b523a8d59a..ca6565b0e45e 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 Fri Apr 12 14:47:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 88431 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 6EBC6384AB67 for ; Fri, 12 Apr 2024 14:50:56 +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 7E9BA3858408 for ; Fri, 12 Apr 2024 14:47:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7E9BA3858408 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 7E9BA3858408 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=1712933257; cv=none; b=pgfbR0Pb9pWW5+kW0OFY+uhOWHPAmHUUfgcdADiozeNiN0RFcM2dCLsQjHvX6eiFZ1Tj2BiUdcjkKpa3URPu1XiBEniQssKXd6l679RwxcqhiXZvLOEe1DDeDqt1nxPxsSTBunfotJ7QuccMj1jzo7YdaWzMEfEdTcFg2bmiHng= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712933257; c=relaxed/simple; bh=M2BcrQfBEr87Vr7GiSIC2d309jVygBKIdoq9Xfuweik=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=WukiWj1GO/M+/S48ZnhxeAY4sy+Qqa6tkr0GOhd2rsI1gvtPqZbd+KgMzdqIIneUlg8gTZrZU/qTPq9LBybn+8pTaIY8jNz+y0uAhAR4PQIxw0ZVOa8GL/1Ejnoa1WqQLxq4o7+8gXOR1PpXj2HVzgSUnd/j4k9e3FoV8Pg6DxU= 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.17.1.19/8.17.1.19) with ESMTP id 43CEh6mG002958; Fri, 12 Apr 2024 14:47:31 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=gfJjW+jukkqNK/Qqtm2ywGvgUZc/U2YxNanBJ2mzaqY=; b=IpwdhICTci5xxidf/gtaHWEl6wmPS0y2QJutG86uxLZvraDDxaCXvJOTo9gE2J32Y+ot 7BAWRvY0bDoCbvS72XolHlR57bHrsfZIJCGPe+dSZg72FWmByq+LBk6ROqm8iuaELhYQ J24DwXQTn9olxjrXBknKMs5IBebOpt6l4woC58tGbXuiWllNNMM9k5B95NYdSWM9oOIO 9JVr39Oouam3PTofCXyJ65Hq/GMcXBVtqliaD9fd/7M7VtukX28md4SmbZEWpizg1O7j mWPfCpmpCk5J7VHj8e1t+cVfmamoGy6iDDRfUBDgga6hNggcSraFdvWIcVHNPdVdOsrV iA== 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 3xf5b4g7t6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:31 +0000 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 43CBVUYU029889; Fri, 12 Apr 2024 14:47:30 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xbj7mt9jn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 14:47:30 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CElO9i37028296 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 14:47:26 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C8B22004B; Fri, 12 Apr 2024 14:47:24 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7189420073; Fri, 12 Apr 2024 14:47:24 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 14:47:24 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v3 15/15] gas: Validate SFrame RA tracking and fixed RA offset Date: Fri, 12 Apr 2024 16:47:18 +0200 Message-Id: <20240412144718.4191286-16-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240412144718.4191286-1-jremus@linux.ibm.com> References: <20240412144718.4191286-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: _JOkmZMdu_4MidrR5X8kswbxVdWdG9_t X-Proofpoint-GUID: _JOkmZMdu_4MidrR5X8kswbxVdWdG9_t X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_11,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 phishscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 impostorscore=0 mlxscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120107 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_H4, 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 If an architecture uses SFrame return-address (RA) tracking it must specify the fixed RA offset as invalid. Otherwise, if an architecture does not use RA tracking, it must specify a valid fixed RA offset. gas/ * gen-sframe.c: Validate SFrame RA tracking and fixed RA offset. Signed-off-by: Jens Remus --- Notes (jremus): Changes v2 -> v3: - New patch. This could be made dependent on ENABLE_CHECKING (configure option --enable-checking). gas/gen-sframe.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index ca6565b0e45e..7e815f9603ef 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1532,6 +1532,18 @@ output_sframe (segT sframe_seg) /* Setup the version specific access functions. */ sframe_set_version (SFRAME_VERSION_2); +#ifdef SFRAME_FRE_RA_TRACKING + if (sframe_ra_tracking_p ()) + /* With RA tracking the fixed RA offset must be invalid. */ + gas_assert (sframe_cfa_ra_offset () == SFRAME_CFA_FIXED_RA_INVALID); + else + /* Without RA tracking the fixed RA offset may not be invalid. */ + gas_assert (sframe_cfa_ra_offset () != SFRAME_CFA_FIXED_RA_INVALID); +#else + /* Without RA tracking the fixed RA offset may not be invalid. */ + gas_assert (sframe_cfa_ra_offset () != SFRAME_CFA_FIXED_RA_INVALID); +#endif + /* Process all fdes and create SFrame stack trace information. */ create_sframe_all ();