From patchwork Mon Jun 24 14:23:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92828 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 028AD3843892 for ; Tue, 25 Jun 2024 10:51:35 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 23324386D61D for ; Tue, 25 Jun 2024 10:51:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23324386D61D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 23324386D61D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719312663; cv=none; b=RiRfKNFuy0vlMcgVJBsUklU0ARWEPnoTo9HobUchNQsgKTT9+GpHnjNuBrMpDbyezXkJPLRE9zpv21BiVgx+Sf7ZCzFkvvvbKIapIOyTiuHOTd58Og/1mNExJr8XY530VowZx9TBKz6O2KY3QPWNc8BHkTLBcXO82z7Md+VyhJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719312663; c=relaxed/simple; bh=5+tVaB4Vs742m/LoYmtpgM9BKyKsDycC/iUGrddmBGo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=qNP1KVGVpYRB7NRb7esqC7KwKvkxGZ0JMZrELCs72Dh4OAaDgEUjjsjUOo7wPbcXHsXj82jdSx/KpIE1P1GLH1ViA+tHrqakqbwq0UsPln4peHjWuDsXFv6d0xv8+DOhe6UFOWtX7AzbcuVcmR+52ODuq9XqFjxcO9y7kDslxso= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45OETcME021954; Mon, 24 Jun 2024 14:49:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=cLo0ptnAv3Idk R7tLojJIJ8eTx9IMQw4ICZiHXppdHY=; b=Uxx2+eTOLWP9po4yhcp+bliLNutDt jzJErqoSVSLMU65pyleTsolCvcvZQA9ooNLlGnM9CrW6gISt+Cul17H4kw+40Yu9 gG3KCs4sYDWCeHIRpDCgOIKBOlsIccB+6JbKr50h8I0fl1IxrsTgE3mRsinUivJQ Z5fck/hGumhD3khyXEw9B9Ocry87oxlaclts2sxNf/Ekt5BHZ0EnZEwEs0EBcogt zjQoTpWxiEl/JMvGc+08tGqsOTNeHpTVn7oeuNr91U88BWV6EJXGrHzesK/b6Zik Fe3L+/7rkQWzD8St5U5rAUlwD3+hIUqLfzkhlTsq7m3czkYqqH1J1eWgA== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yyakug1xp-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:49:42 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45ODt6KO019897; Mon, 24 Jun 2024 14:23:43 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yxb5m8xs9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:43 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENcmi56099090 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:40 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B3F82006A; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E5B1D20067; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:37 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 06/15] gas: Skip SFrame FDE if CFI specifies non-FP/SP base register Date: Mon, 24 Jun 2024 16:23:25 +0200 Message-Id: <20240624142334.3283823-7-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: zihIrjdCWxchgfhzkO8B4B5NJ017Kwbi X-Proofpoint-ORIG-GUID: zihIrjdCWxchgfhzkO8B4B5NJ017Kwbi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org Do not generate SFrame FDE if DWARF CFI directives .cfi_def_cfa or .cfi_def_cfa_register specify a CFA base register number other than the architecture-specific stack-pointer (SP) or frame-pointer (FP) register numbers. This also causes the assembler to print a warning message, so that skipping of the SFrame FDE does not occur silently. Update the generic ld SFrame test case to be architecture independent. Do not use CFI directive .cfi_def_cfa, as the specified CFA base register number is not a valid SP/FP register number on all architectures. An invalid SP/FP register number will now cause the assembler to print a warning message and skip SFrame FDE generation. Remove the offending CFI directive, that cannot be coded architecture- independent, as the test case requires SFrame information to be generated. This was reported by the Linaro-TCWG-CI for AArch64. gas/ * gen-sframe.c: Skip SFrame generation if CFI specifies non-FP/SP base register. ld/testsuite/ * ld-sframe/discard.s: Update generic SFrame test case to be architecture independent. Reviewed-by: Andreas Krebbel Reviewed-by: Indu Bhagat Signed-off-by: Jens Remus --- Notes (jremus): Changes v2 -> v3: - Corrected formatting of ChangeLog in commit message. Changes v1 -> v2: - Update generic SFrame test case to be architecture independent to resolve generic ld SFrame test case failure reported by Linaro-TCWG-CI for AArch64. It would fail similar on s390x. Without this patch the assembler would erroneously generate bad SFrame information for the s390-specific SFrame error test cases 1 and 2, that get introduced by patch "s390: Initial support to generate .sframe from CFI directives in assembler". gas/gen-sframe.c | 13 +++++++++++-- ld/testsuite/ld-sframe/discard.s | 1 - 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 116d1f48f781..52c2f3f4ff89 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -988,7 +988,11 @@ sframe_xlate_do_def_cfa (struct sframe_xlate_ctx *xlate_ctx, get_dw_fde_start_addrS (xlate_ctx->dw_fde)); } /* Define the current CFA rule to use the provided register and - offset. */ + offset. However, if the register is not FP/SP, skip creating + SFrame stack trace info for the function. */ + if (cfi_insn->u.r != SFRAME_CFA_SP_REG + && cfi_insn->u.r != SFRAME_CFA_FP_REG) + return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ sframe_fre_set_cfa_base_reg (cur_fre, cfi_insn->u.ri.reg); sframe_fre_set_cfa_offset (cur_fre, cfi_insn->u.ri.offset); cur_fre->merge_candidate = false; @@ -1006,9 +1010,14 @@ sframe_xlate_do_def_cfa_register (struct sframe_xlate_ctx *xlate_ctx, struct sframe_row_entry *last_fre = xlate_ctx->last_fre; /* Get the scratchpad FRE. This FRE will eventually get linked in. */ struct sframe_row_entry *cur_fre = xlate_ctx->cur_fre; + gas_assert (cur_fre); /* Define the current CFA rule to use the provided register (but to - keep the old offset). */ + keep the old offset). However, if the register is not FP/SP, + skip creating SFrame stack trace info for the function. */ + if (cfi_insn->u.r != SFRAME_CFA_SP_REG + && cfi_insn->u.r != SFRAME_CFA_FP_REG) + return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ sframe_fre_set_cfa_base_reg (cur_fre, cfi_insn->u.ri.reg); sframe_fre_set_cfa_offset (cur_fre, last_fre->cfa_offset); cur_fre->merge_candidate = false; diff --git a/ld/testsuite/ld-sframe/discard.s b/ld/testsuite/ld-sframe/discard.s index a438b42bffa1..5591a50d486a 100644 --- a/ld/testsuite/ld-sframe/discard.s +++ b/ld/testsuite/ld-sframe/discard.s @@ -5,7 +5,6 @@ foo: .cfi_startproc .cfi_def_cfa_offset 16 - .cfi_def_cfa 7, 8 .cfi_endproc .globl _start