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