From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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; } -- 2.40.1