From patchwork Fri Feb 23 17:07:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 205524 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp718808dyb; Fri, 23 Feb 2024 09:08:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXX0QGRLDi8ycJSWY5ghv9OItDXTAyjJnLS3w+DDHgZ6mMPctf3XRs8uHk5xaEAOC74yDZuALPtggn4usuUDGedCppIRA== X-Google-Smtp-Source: AGHT+IHpo+eXOQcXtIaM6QdFYh7Nr7NWrfi6+F4c9JUbHdmoXV/mXo2sGUHwSm6lBwmqaHMjJrnW X-Received: by 2002:a05:620a:b12:b0:787:1c2f:b12e with SMTP id t18-20020a05620a0b1200b007871c2fb12emr386862qkg.50.1708708105167; Fri, 23 Feb 2024 09:08:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708708105; cv=pass; d=google.com; s=arc-20160816; b=Gi/0mKrSK4hrs+QAvIayYyrP5GKt9nAzHlMJUUu5Rxb8sJ/CZLY1hQ1RSOoH0zJnn5 oDrvJ+dUhT66wDGHoXWzFbejmK2LpWe+sUtLqycEvhu2pHGjlnMiJm65R0kHgBGcg4u7 idRXMHE86SO5xpQQAbjM58y1cHKx+isLYQ0MnN8/+3rE7od/ZRK7kZIXYjCcDAhQoZCl JjKS5TQusvmn1awJ+iGnV6kf/ed+4MU9eq0RQOxshpVvIYELr1zUPm78KZ+km4LgxHOM 6AfbtMFR4Y0Zn8/X89le9kLaiZ+CTW2H1WiUPU7Jr1CHu9Up2ej50t1rq+FqzZgLHMS2 d0vA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=qFr8JF3+fX9UpdSkT1btPRX0mDAbFLB3LEaGHefXqco=; fh=vTbGg4wY0rLaolKO+EtTu7rlJzNAP3iHbUH+MVoijcQ=; b=uh5qwM6dbSXi/8v6KI1aaH+uVVG8L9pmMSpI7Jesy7zwOQowX1k4y/YbLWUFXQr4hX XMuw202C1OYLANdk4zekWeCoyvV4iaHKpEhFPTQNl7Jksd23/rdHKh5RojJNM0VKdQAU ss0x7caH6uKaKDxwvkecSnFt2ORjgYYsfeGkEnZAIe0sfuvbB+ErVw8MzWWmO2vxqNQl Nc/TbBP/LDor0Ikqc1LEhcjfWfo5WDat2Q4TUzREovqW8XfEbnqRlwqeEib4cl1YOFFT +3Ne9rxSpcYMq9V+9X/q0j4Jmh8sJ7NKDIOTZnBPrfJ8IBzwVxyBEaZzGYAhLrnosnWv lAdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=TPctXi3T; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id bk28-20020a05620a1a1c00b00787a8cdf6dasi3106154qkb.66.2024.02.23.09.08.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 09:08:25 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=TPctXi3T; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AF3E83858429 for ; Fri, 23 Feb 2024 17:08:24 +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 037653858C50 for ; Fri, 23 Feb 2024 17:08:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 037653858C50 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 037653858C50 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=1708708095; cv=none; b=eRQ0XERNGmQxvduzGttTQ1t3+HraYZ6YK56IYpudjDbog9PLANS4XpEejxgvRYPQ7LiMGaY6WQcTEUV6WaIFPOiLfqdoly8QGD/oqjkTEG73Y0tYOmi/UhXLMtXV0cwX3H4zfuIsvumY78AHEMwlBtOupVOttEHCPa21zonb1WM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708708095; c=relaxed/simple; bh=Cg33LcJSpUQtaANQu7Ko15+0gqIW2THxGap2LAEUUM8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ejaE0QBeIGkJRkq5CQ5UP79UOSGfsTSgaj5Vl/A8NQezs3aKVyE6PsvlBrh5IYgnds7pM89Ro8bheygh/T0EoI2Q/9ctr2NhSXm+yg2aeW2bjD4B10pYNKG/E5vUopkzN2tS6DSg+oCovIoC3+t4cSI6enDfDRwiXLyudbcMB9Y= 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 41NGuRLu027765; Fri, 23 Feb 2024 17:08:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=qFr8JF3+fX9UpdSkT1btPRX0mDAbFLB3LEaGHefXqco=; b=TPctXi3Th4iUZvakCUL7McrZdvz/1KxjPhzIs4kJO37ooaAZlLpUuFGeVMJN86Yb2C5i C+rH7y5uD2WVH/PWoFv5aUgzxePMe2YhrDSL/K7ge9589+Meo9qTlY0hEpnMmtduVpK3 7dpm7MG0yObJU+j5pbvfiL7JtU+2/qTVeO/3QUEIc5GO+47hbjlZ8TidWVWTZoXYaEqm WmnAxWu+iTawUflKMBfebE7WW/GijmrT8ATP6WOeww42/FhgDjjXMGaKKfnhCFtiReIs vGUeLIcPkxJx29kDupar+TTT+Kijwl6GhSxZPY8CoVPnhH+4FVpWgDnlG4/T3pUpzx0r Rw== 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 3wexyu0s3f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Feb 2024 17:08:08 +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 41NH47PI009547; Fri, 23 Feb 2024 17:08:08 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wb84pxs1g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Feb 2024 17:08:07 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41NH84Om49545548 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Feb 2024 17:08:06 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D83FF20043; Fri, 23 Feb 2024 17:08:03 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B1B6320069; Fri, 23 Feb 2024 17:08:03 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 23 Feb 2024 17:08:03 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v2 6/9] gas: Skip SFrame FDE if CFI specifies non-FP/SP base register Date: Fri, 23 Feb 2024 18:07:57 +0100 Message-Id: <20240223170800.3993092-7-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240223170800.3993092-1-jremus@linux.ibm.com> References: <20240223170800.3993092-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: I4f76OPZKKG0fWISczczcz1DThciOqeu X-Proofpoint-ORIG-GUID: I4f76OPZKKG0fWISczczcz1DThciOqeu 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-02-23_03,2024-02-23_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxscore=0 phishscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 suspectscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402230124 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: 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+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791710309890641389 X-GMAIL-MSGID: 1791710309890641389 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 Signed-off-by: Jens Remus --- Notes (jremus): 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