From patchwork Mon Jun 24 14:23:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Remus X-Patchwork-Id: 92777 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 77FED384AB4E for ; Mon, 24 Jun 2024 16:56:59 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id B501D3858D35 for ; Mon, 24 Jun 2024 16:56:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B501D3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B501D3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719248193; cv=none; b=bjbMmt2tKw3blAd2eH/GUtkDY+qGxSiNs1uU6+yAoUXKzDBGPnWwzeLfpxhC71vmjaDO8Pwj3LgNKrH42x4Vv9qNY6W+Sscj2VFo4FjQFmnSvm6GzeEIiGk8yvyS44ddSv4EjDlL5jVLwUQRVmEZAowFgUPUrrqNpbfTPbJmF1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719248193; c=relaxed/simple; bh=BtXe62wsqQerdJZ68IEoskyb4TlmgVvEgUO1V0mZr8Q=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=VqHivl1mXVnz+05eNFePpQo94ITTHQ9afj7BrdooBaV0vYFVQ6eZjQTzHsroI98+l5PumE7bMCtSxlDEU2aep2Q7kqAwhU+59vMAO+AhptUHwwOw1uD+fU8GNarw0SJNyj5+9SRh/HvDo/1rAZ56Hs65AlOM3iyddYOAJRctaBk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45OEQn9o010590; Mon, 24 Jun 2024 14:26:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=hvflbSFxIajPk gD9LLwwkJA+wXNufJntIX8YZMPudkA=; b=iaYsjTCFtEFX2gtC5Caqg8Eg6B9wz R8aIkWhYJXzLk5OcheAUn97M1rX/CeYkrzSdXytulRspHfDZ8e87svBqlaYh+s38 zArR4XUyqwyKAWzYKYdRDq6wELd02gR5nYcXErdFRidKOGKeWdkaotW/4qNMpA+b 2uMDtZyqjftiR4FcKwQZeGM20kOSB0DEhFhoGeHmV81SmjaGZ4eUb+SEQWYwpM4E yRjXfUNRZ8dzwjtsJPXuxd1eB6pPOS6LPZdr0tCdgTGTXgS07GLoULJVoOkDT2Qh vMCn216gZNwIV3ViHsuB6xSrdBqOjrK4XsFjfTUOW0qdF+LRp6Jk6EHpA== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yy8u4rah3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:26:49 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45OBwH6A018093; Mon, 24 Jun 2024 14:23:45 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yx8xu1eu1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 14:23:45 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45OENeQF56099092 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2024 14:23:42 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82D792005A; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6898D20071; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 24 Jun 2024 14:23:38 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [PATCH v4 10/15] gas: Skip SFrame FDE if FP without RA on stack Date: Mon, 24 Jun 2024 16:23:29 +0200 Message-Id: <20240624142334.3283823-11-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240624142334.3283823-1-jremus@linux.ibm.com> References: <20240624142334.3283823-1-jremus@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ZGCbTn-Dxc00rtA1F-9-sLxHd0BFQJoo X-Proofpoint-GUID: ZGCbTn-Dxc00rtA1F-9-sLxHd0BFQJoo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_11,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 priorityscore=1501 adultscore=0 clxscore=1015 malwarescore=0 bulkscore=0 impostorscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240115 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org The SFrame format cannot represent the frame pointer (FP) being saved on the stack without the return address (RA) also being saved on the stack, if RA tracking is used. A SFrame FDE is followed by 1-3 offsets with the following information: Without RA tracking: 1. Offset from base pointer (SP or FP) to locate the CFA 2. Optional: Offset to CFA to restore the frame pointer (FP) With RA tracking: 1. Offset from base pointer (SP or FP) to locate the CFA 2. Optional: Offset to CFA to restore the return address (RA) 3. Optional: Offset to CFA to restore the frame pointer (FP) When RA tracking is used and a FDE is followed by two offsets the SFrame format does not provide any information to distinguish whether the second offset is the RA or FP offset. SFrame assumes the offset to be the RA offset, which may be wrong. Therefore skip generation of SFrame FDE information and print the following warning, if RA tracking is used and the FP is saved on the stack without the RA being saved as well: skipping SFrame FDE; FP without RA on stack gas/ * gen-sframe.c (sframe_do_fde): Skip SFrame FDE if FP without RA on stack, as the SFrame format cannot represent this case. Reviewed-by: Indu Bhagat Signed-off-by: Jens Remus --- Notes (jremus): Changes v3 -> v4: - Dropped misleading comment "No errors encountered". as suggtested by Indu. - Changed warning message text as follows for consistency: skipping SFrame FDE; FP without RA on stack Changes v2 -> v3: - New patch. Without this patch the assembler would generate incorrect SFrame information without warning for the s390-specific SFrame error test case 5, that gets introduced by patch "s390: Initial support to generate .sframe from CFI directives in assembler". The FRE would be followed by two offsets for the CFA and FP. SFrame would erroneously interpret them as CFA and RA offsets, as it cannot represent FP without RA on stack. gas/gen-sframe.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 3d9824a7a080..c29c407cc86f 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1423,8 +1423,6 @@ sframe_do_fde (struct sframe_xlate_ctx *xlate_ctx, } } - /* No errors encountered. */ - /* Link in the scratchpad FRE that the last few CFI insns helped create. */ if (xlate_ctx->cur_fre) { @@ -1438,6 +1436,25 @@ sframe_do_fde (struct sframe_xlate_ctx *xlate_ctx, = get_dw_fde_end_addrS (xlate_ctx->dw_fde); } +#ifdef SFRAME_FRE_RA_TRACKING + if (sframe_ra_tracking_p ()) + { + struct sframe_row_entry *fre; + + /* Iterate over the scratchpad FREs and validate them. */ + for (fre = xlate_ctx->first_fre; fre; fre = fre->next) + { + /* SFrame format cannot represent FP on stack without RA on stack. */ + if (fre->ra_loc != SFRAME_FRE_ELEM_LOC_STACK + && fre->bp_loc == SFRAME_FRE_ELEM_LOC_STACK) + { + as_warn (_("skipping SFrame FDE; FP without RA on stack")); + return SFRAME_XLATE_ERR_NOTREPRESENTED; + } + } + } +#endif /* SFRAME_FRE_RA_TRACKING */ + return SFRAME_XLATE_OK; }