[PATCH v1 3/4] Enable arch-specific CFI directives and DWARF instructions only when required by the target

Jens Remus jremus@linux.ibm.com
Thu Dec 12 09:26:10 GMT 2024


On 11.12.2024 13:05, Matthieu Longo wrote:
> This patch is a follow-up on the patch adding a TC_<arch> definition in
> the different modules of binutils interacting with DWARF in one way or
> another. It surrounds the architecture-specific code for DWARF instructions
> and CFI directives with the corresponding TC_<arch> definition to enable
> or disable it according to the selected target in configure (via --target).

...

> diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c
> index 0e100ef231c..12c92774a7d 100644
> --- a/gas/gen-sframe.c
> +++ b/gas/gen-sframe.c
> @@ -1265,6 +1265,8 @@ sframe_xlate_do_restore (struct sframe_xlate_ctx *xlate_ctx,
>     return SFRAME_XLATE_OK;
>   }
>   
> +#if TC_AARCH64
> +
>   /* Translate DW_CFA_AARCH64_negate_ra_state into SFrame context.
>      Return SFRAME_XLATE_OK if success.  */
>   
> @@ -1295,6 +1297,10 @@ sframe_xlate_do_aarch64_negate_ra_state_with_pc (struct sframe_xlate_ctx *xlate_
>     return SFRAME_XLATE_ERR_NOTREPRESENTED;  /* Not represented.  */
>   }
>   
> +#endif /* TC_AARCH64 */
> +
> +#if TC_SPARC
> +
>   /* Translate DW_CFA_GNU_window_save into SFrame context.
>      DW_CFA_GNU_window_save is a DWARF Sparc extension, but is multiplexed with a
>      directive of DWARF AArch64 extension: DW_CFA_AARCH64_negate_ra_state.
> @@ -1306,20 +1312,15 @@ sframe_xlate_do_aarch64_negate_ra_state_with_pc (struct sframe_xlate_ctx *xlate_
>      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)
> +sframe_xlate_do_gnu_window_save (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED,
> +				 struct cfi_insn_data *cfi_insn ATTRIBUTE_UNUSED)
>   {
> -  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; .cfi_window_save"));
>     return SFRAME_XLATE_ERR_NOTREPRESENTED;  /* Not represented.  */
>   }
>   
> +#endif /* TC_SPARC */
> +

Both TC_SPARC blocks can be omitted. The purpose of
sframe_xlate_do_gnu_window_save() was to actually handle the
multiplexed DW_CFA_AARCH64_negate_ra_state on AArch64 and
otherwise skip generation of the SFrame FDE with a warning
message. See my next comment.

>   /* Returns the DWARF call frame instruction name or fake CFI name for the
>      specified CFI opcode, or NULL if the value is not recognized.  */
>   
> @@ -1405,14 +1406,19 @@ sframe_do_cfi_insn (struct sframe_xlate_ctx *xlate_ctx,
>       case DW_CFA_restore:
>         err = sframe_xlate_do_restore (xlate_ctx, cfi_insn);
>         break;
> -    /* DW_CFA_AARCH64_negate_ra_state is multiplexed with
> -       DW_CFA_GNU_window_save.  */
> -    case DW_CFA_GNU_window_save:
> -      err = sframe_xlate_do_gnu_window_save (xlate_ctx, cfi_insn);
> +#if TC_AARCH64
> +    case DW_CFA_AARCH64_negate_ra_state:
> +      err = sframe_xlate_do_aarch64_negate_ra_state (xlate_ctx, cfi_insn);
>         break;
>       case DW_CFA_AARCH64_negate_ra_state_with_pc:
>         err = sframe_xlate_do_aarch64_negate_ra_state_with_pc (xlate_ctx, cfi_insn);
>         break;
> +#endif /* TC_AARCH64 */
> +#if TC_SPARC
> +    case DW_CFA_GNU_window_save:
> +      err = sframe_xlate_do_gnu_window_save (xlate_ctx, cfi_insn);
> +      break;
> +#endif /* TC_SPARC */

Omitting the TC_SPARC block will trigger skipping of the SFrame FDE
with a warning message in the default case for all architectures,
except AArch64, which handles DW_CFA_AARCH64_negate_ra_state above.

>       case DW_CFA_register:
>         err = sframe_xlate_do_register (xlate_ctx, cfi_insn);
>         break;

...

Regards,
Jens
-- 
Jens Remus
Linux on Z Development (D3303) and z/VSE Support
+49-7031-16-1128 Office
jremus@de.ibm.com

IBM

IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/



More information about the Binutils mailing list