From: Indu Bhagat <indu.bhagat@oracle.com>
To: Jens Remus <jremus@linux.ibm.com>, binutils@sourceware.org
Cc: Andreas Krebbel <krebbel@linux.ibm.com>
Subject: Re: [PATCH v3 03/15] readelf/objdump: Dump SFrame CFA fixed FP and RA offsets
Date: Thu, 18 Apr 2024 00:39:57 -0700 [thread overview]
Message-ID: <c72370bc-99ff-4afe-8ed1-b9dd7d497bbc@oracle.com> (raw)
In-Reply-To: <20240412144718.4191286-4-jremus@linux.ibm.com>
On 4/12/24 07:47, Jens Remus wrote:
> 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 <krebbel@linux.ibm.com>
> Signed-off-by: Jens Remus <jremus@linux.ibm.com>
LGTM.
Thanks for your patch.
> ---
>
> 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);
>
next prev parent reply other threads:[~2024-04-18 7:40 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-12 14:47 [PATCH v3 00/15] sframe: Enhancements to SFrame info generation Jens Remus
2024-04-12 14:47 ` [PATCH v3 01/15] x86: Remove unused SFrame CFI RA register variable Jens Remus
2024-04-12 14:47 ` [PATCH v3 02/15] gas: Enhance arch-specific SFrame configuration descriptions Jens Remus
2024-04-18 7:39 ` Indu Bhagat
2024-05-03 12:30 ` Jens Remus
2024-04-12 14:47 ` [PATCH v3 03/15] readelf/objdump: Dump SFrame CFA fixed FP and RA offsets Jens Remus
2024-04-18 7:39 ` Indu Bhagat [this message]
2024-04-12 14:47 ` [PATCH v3 04/15] readelf/objdump: Display SFrame fixed RA offset as 'f' in dump Jens Remus
2024-04-18 7:40 ` Indu Bhagat
2024-04-12 14:47 ` [PATCH v3 05/15] gas: Print DWARF call frame insn name in SFrame warning message Jens Remus
2024-04-18 7:40 ` Indu Bhagat
2024-04-12 14:47 ` [PATCH v3 06/15] gas: Skip SFrame FDE if CFI specifies non-FP/SP base register Jens Remus
2024-04-18 7:40 ` Indu Bhagat
2024-04-12 14:47 ` [PATCH v3 07/15] gas: Warn if SFrame FDE is skipped due to non-default return column Jens Remus
2024-04-18 7:40 ` Indu Bhagat
2024-04-12 14:47 ` [PATCH v3 08/15] gas: Refactor SFrame CFI opcode DW_CFA_register processing Jens Remus
2024-04-18 7:40 ` Indu Bhagat
2024-04-12 14:47 ` [PATCH v3 09/15] gas: User readable warnings if SFrame FDE is not generated Jens Remus
2024-04-18 20:33 ` Indu Bhagat
2024-05-03 12:30 ` Jens Remus
2024-05-03 23:41 ` Indu Bhagat
2024-04-12 14:47 ` [PATCH v3 10/15] gas: Skip SFrame FDE if FP without RA on stack Jens Remus
2024-04-16 13:14 ` Jens Remus
2024-04-17 23:56 ` Indu Bhagat
2024-04-18 10:27 ` Jens Remus
2024-04-18 20:35 ` Indu Bhagat
2024-04-12 14:47 ` [PATCH v3 11/15] gas: Skip SFrame FDE if .cfi_window_save Jens Remus
2024-04-18 20:36 ` Indu Bhagat
2024-04-12 14:47 ` [PATCH v3 12/15] gas: Don't skip SFrame FDE if .cfi_register specifies RA w/o tracking Jens Remus
2024-04-18 20:36 ` Indu Bhagat
2024-04-12 14:47 ` [PATCH v3 13/15] gas: Don't skip SFrame FDE if .cfi_register specifies SP register Jens Remus
2024-04-18 20:37 ` Indu Bhagat
2024-04-19 13:13 ` Jens Remus
2024-04-23 8:15 ` Indu Bhagat
2024-04-25 22:22 ` Indu Bhagat
2024-04-12 14:47 ` [PATCH v3 14/15] gas: Test predicate whether SFrame RA tracking is used Jens Remus
2024-04-18 20:37 ` Indu Bhagat
2024-04-12 14:47 ` [PATCH v3 15/15] gas: Validate SFrame RA tracking and fixed RA offset Jens Remus
2024-04-18 20:38 ` Indu Bhagat
2024-05-03 16:40 ` Jens Remus
2024-05-04 0:22 ` Indu Bhagat
2024-05-06 11:41 ` Jens Remus
2024-05-06 14:39 ` Jens Remus
2024-05-16 20:45 ` Indu Bhagat
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c72370bc-99ff-4afe-8ed1-b9dd7d497bbc@oracle.com \
--to=indu.bhagat@oracle.com \
--cc=binutils@sourceware.org \
--cc=jremus@linux.ibm.com \
--cc=krebbel@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).