[PATCH,V2 3/4] gas: sframe: handle .cfi_undefined

Indu Bhagat indu.bhagat@oracle.com
Fri May 16 21:07:00 GMT 2025


On 5/16/25 9:06 AM, Jens Remus wrote:
> On 15.05.2025 23:06, Indu Bhagat wrote:
>> Fix PR gas/32952 - sframe: incorrect handling of .cfi_undefined in gas
>>
>> In context of SFrame generation, it is incorrect to simply ignore all
>> .cfi_undefined.  We may ignore only those .cfi_undefined which are for
>> registers of no interest (similar to whats done for other CFI
>> directives).
> 
>> diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c
> 
>> +static int
>> +sframe_xlate_do_cfi_undefined (const struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED,
>> +			       const struct cfi_insn_data *cfi_insn)
>> +{
>> +  if (cfi_insn->u.r == SFRAME_CFA_FP_REG
>> +      || cfi_insn->u.r == SFRAME_CFA_RA_REG
>> +      || cfi_insn->u.r == SFRAME_CFA_SP_REG)
> 
> I am undecided whether SFrame should ignore .cfi_undefined <SP> (see
> reasoning in my reply to "[PATCH,V2 4/4] gas: sframe: handle
> .cfi_same_value").  Due to the implicit CFA-rule a SFrame based stack
> tracer should always be able to restore SP.
> 
> But in this particular context I tend to assume that .cfi_undefined <SP>
> would indicate somthing fishy and SFrame should better skip emitting the
> FDE.
> 

Exactly.

As you see, there are valid reasons to be on either side of the 
argument. I too have a preference to warn and skip FDE for the same 
reason as yours, hence the code.

>> +    {
>> +      as_warn (_("no SFrame FDE emitted; %s reg %u in .cfi_undefined"),
>> +	       sframe_register_name (cfi_insn->u.r), cfi_insn->u.r);
>> +      return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented.  */
>> +    }
>> +
>> +  /* Safe to skip.  */
>> +  return SFRAME_XLATE_OK;
>> +}
> 
> Regards,
> Jens



More information about the Binutils mailing list