[v3,11/15] gas: Skip SFrame FDE if .cfi_window_save

Message ID 20240412144718.4191286-12-jremus@linux.ibm.com
State New
Headers
Series sframe: Enhancements to SFrame info generation |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Testing passed

Commit Message

Jens Remus April 12, 2024, 2:47 p.m. UTC
  CFI opcode DW_CFA_AARCH64_negate_ra_state is multiplexed with
DW_CFA_GNU_window_save. Process DW_CFA_AARCH64_negate_ra_state on
AArch64. Skip generation of SFrame FDE otherwise.

gas/
	* gen-sframe.c: Skip SFrame FDE if .cfi_window_save.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---

Notes (jremus):
    Changes v2 -> v3:
    - New patch. The intention is to skip all "unknown" CFI opcodes,
      which SFrame does not explicitly handle. DW_CFA_GNU_window_save
      seems to be handled only for the AArch64-specific multiplexed
      DW_CFA_AARCH64_negate_ra_state. The logic could be changed to be
      dependent on TC_AARCH64 at build-time instead of
      sframe_get_abi_arch() at run-time.

 gas/gen-sframe.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
  

Comments

Indu Bhagat April 18, 2024, 8:36 p.m. UTC | #1
On 4/12/24 07:47, Jens Remus wrote:
> CFI opcode DW_CFA_AARCH64_negate_ra_state is multiplexed with
> DW_CFA_GNU_window_save. Process DW_CFA_AARCH64_negate_ra_state on
> AArch64. Skip generation of SFrame FDE otherwise.
> 
> gas/
> 	* gen-sframe.c: Skip SFrame FDE if .cfi_window_save.
> 

LGTM.

Thanks

> Signed-off-by: Jens Remus <jremus@linux.ibm.com>
> ---
> 
> Notes (jremus):
>      Changes v2 -> v3:
>      - New patch. The intention is to skip all "unknown" CFI opcodes,
>        which SFrame does not explicitly handle. DW_CFA_GNU_window_save
>        seems to be handled only for the AArch64-specific multiplexed
>        DW_CFA_AARCH64_negate_ra_state. The logic could be changed to be
>        dependent on TC_AARCH64 at build-time instead of
>        sframe_get_abi_arch() at run-time.
> 
>   gas/gen-sframe.c | 25 ++++++++++++++++++++++---
>   1 file changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c
> index 87be3eb05ad2..98166de8cc01 100644
> --- a/gas/gen-sframe.c
> +++ b/gas/gen-sframe.c
> @@ -1257,12 +1257,12 @@ sframe_xlate_do_restore (struct sframe_xlate_ctx *xlate_ctx,
>     return SFRAME_XLATE_OK;
>   }
>   
> -/* Translate DW_CFA_GNU_window_save into SFrame context.
> +/* Translate DW_CFA_AARCH64_negate_ra_state into SFrame context.
>      Return SFRAME_XLATE_OK if success.  */
>   
>   static int
> -sframe_xlate_do_gnu_window_save (struct sframe_xlate_ctx *xlate_ctx,
> -				 struct cfi_insn_data *cfi_insn ATTRIBUTE_UNUSED)
> +sframe_xlate_do_aarch64_negate_ra_state (struct sframe_xlate_ctx *xlate_ctx,
> +					 struct cfi_insn_data *cfi_insn ATTRIBUTE_UNUSED)
>   {
>     struct sframe_row_entry *cur_fre = xlate_ctx->cur_fre;
>   
> @@ -1274,6 +1274,25 @@ sframe_xlate_do_gnu_window_save (struct sframe_xlate_ctx *xlate_ctx,
>     return SFRAME_XLATE_OK;
>   }
>   
> +/* Translate DW_CFA_GNU_window_save into SFrame context.
> +   DW_CFA_AARCH64_negate_ra_state is multiplexed with DW_CFA_GNU_window_save.
> +   Return SFRAME_XLATE_OK if success.  */
> +
> +static int
> +sframe_xlate_do_gnu_window_save (struct sframe_xlate_ctx *xlate_ctx,
> +				 struct cfi_insn_data *cfi_insn)
> +{
> +  unsigned char abi_arch = sframe_get_abi_arch ();
> +
> +  /* Translate DW_CFA_AARCH64_negate_ra_state into SFrame context.  */
> +  if (abi_arch == SFRAME_ABI_AARCH64_ENDIAN_BIG
> +      || abi_arch == SFRAME_ABI_AARCH64_ENDIAN_LITTLE)
> +    return sframe_xlate_do_aarch64_negate_ra_state (xlate_ctx, cfi_insn);
> +
> +  as_warn (_("skipping SFrame FDE due to .cfi_window_save"));
> +  return SFRAME_XLATE_ERR_NOTREPRESENTED;  /* Not represented.  */
> +}
> +
>   /* Returns the DWARF call frame instruction name or fake CFI name for the
>      specified CFI opcode, or NULL if the value is not recognized.  */
>
  

Patch

diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c
index 87be3eb05ad2..98166de8cc01 100644
--- a/gas/gen-sframe.c
+++ b/gas/gen-sframe.c
@@ -1257,12 +1257,12 @@  sframe_xlate_do_restore (struct sframe_xlate_ctx *xlate_ctx,
   return SFRAME_XLATE_OK;
 }
 
-/* Translate DW_CFA_GNU_window_save into SFrame context.
+/* Translate DW_CFA_AARCH64_negate_ra_state into SFrame context.
    Return SFRAME_XLATE_OK if success.  */
 
 static int
-sframe_xlate_do_gnu_window_save (struct sframe_xlate_ctx *xlate_ctx,
-				 struct cfi_insn_data *cfi_insn ATTRIBUTE_UNUSED)
+sframe_xlate_do_aarch64_negate_ra_state (struct sframe_xlate_ctx *xlate_ctx,
+					 struct cfi_insn_data *cfi_insn ATTRIBUTE_UNUSED)
 {
   struct sframe_row_entry *cur_fre = xlate_ctx->cur_fre;
 
@@ -1274,6 +1274,25 @@  sframe_xlate_do_gnu_window_save (struct sframe_xlate_ctx *xlate_ctx,
   return SFRAME_XLATE_OK;
 }
 
+/* Translate DW_CFA_GNU_window_save into SFrame context.
+   DW_CFA_AARCH64_negate_ra_state is multiplexed with DW_CFA_GNU_window_save.
+   Return SFRAME_XLATE_OK if success.  */
+
+static int
+sframe_xlate_do_gnu_window_save (struct sframe_xlate_ctx *xlate_ctx,
+				 struct cfi_insn_data *cfi_insn)
+{
+  unsigned char abi_arch = sframe_get_abi_arch ();
+
+  /* Translate DW_CFA_AARCH64_negate_ra_state into SFrame context.  */
+  if (abi_arch == SFRAME_ABI_AARCH64_ENDIAN_BIG
+      || abi_arch == SFRAME_ABI_AARCH64_ENDIAN_LITTLE)
+    return sframe_xlate_do_aarch64_negate_ra_state (xlate_ctx, cfi_insn);
+
+  as_warn (_("skipping SFrame FDE due to .cfi_window_save"));
+  return SFRAME_XLATE_ERR_NOTREPRESENTED;  /* Not represented.  */
+}
+
 /* Returns the DWARF call frame instruction name or fake CFI name for the
    specified CFI opcode, or NULL if the value is not recognized.  */