[PATCH,V2 2/2] gas: sframe: partially process DWARF expressions in CFI_escape
Jens Remus
jremus@linux.ibm.com
Thu Feb 6 09:29:39 GMT 2025
On 05.02.2025 00:10, Indu Bhagat wrote:
> Fine tune the handling of CFI_escape for SFrame generation by explicitly
> checking for some "harmless" (in context of SFrame generation)
> CFI_escape DWARF expressions:
> - DW_CFA_expression affecting registers of no significance to SFrame
> stack trace info
> - DW_CFA_value_offset affecting registers of no significance to SFrame
> stack trace info
I successfully tested the DW_CFA_value_offset handling with following
small fix on s390x. A build of Glibc with SFrame no longer skips FDEs
because of .cfi_escape.
> diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c
> +/* Handle DW_CFA_val_offset in .cfi_escape. */
> +
> +static int
> +sframe_xlate_do_escape_val_offset (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED,
> + struct cfi_insn_data *cfi_insn)
> +{
> + const struct cfi_escape_data *e = cfi_insn->u.esc;
> + unsigned int reg = 0;
> + offsetT offset = 0;
> + int err = SFRAME_XLATE_OK;
> + int i = 0;
> +
> + if (!e || !e->next)
> + return SFRAME_XLATE_ERR_INVAL;
> +
> + /* Check for (DW_CFA_val_offset reg scaled_offset) sequence. */
> +#define CFI_ESC_NUM_EXP 2
> + offsetT items[CFI_ESC_NUM_EXP] = {0};
> + while (e->next)
> + {
> + e = e->next;
> + if (i >= CFI_ESC_NUM_EXP)
> + return SFRAME_XLATE_ERR_NOTREPRESENTED;
> + items[i] = e->exp.X_add_number;
> + i++;
> + }
> + if (i <= CFI_ESC_NUM_EXP - 1)
> + return SFRAME_XLATE_ERR_NOTREPRESENTED;
> +
> + reg = items[0];
> + offset = items[1];
> +#undef CFI_ESC_NUM_EXP
> +
> + /* Invoke sframe_xlate_do_val_offset itself for checking. */
> + struct cfi_insn_data *temp = XCNEW (struct cfi_insn_data);
> + temp->insn = DW_CFA_val_offset;
> + temp->u.ri.reg = reg;
> + temp->u.ri.offset = offset;
temp->u.ri.offset = offset * DWARF2_CIE_DATA_ALIGNMENT;
The scaling needs to be undone. Looking at output_cfi_insn() handling
of DW_CFA_val_offset it makes sense to do it in this assignment instead
of when assigning offset = items[1] a few lines above. But that is up
to you.
GAS cfi_add_CFA_val_offset() already has asserted that
DWARF2_CIE_DATA_ALIGNMENT is not zero.
> +
> + err = sframe_xlate_do_val_offset (xlate_ctx, temp, true);
> + XDELETE (temp);
> +
> + return err;
> +}
Regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
+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