[PATCH v2] gas: sframe: Represent .cfi_undefined RA as SFrame FDE without FREs

Jens Remus jremus@linux.ibm.com
Tue Jul 22 14:31:20 GMT 2025


Hello Indu,

thank you for the feedback!

On 22.07.2025 05:00, Indu Bhagat via Binutils wrote:
> On 7/21/25 9:23 AM, Jens Remus wrote:
>> In DWARF CFI an "undefined" register rule for the return address (RA)
>> register indicates that there is no return address and the stack trace
>> is complete.  Represent DW_CFA_undefined as SFrame FDE without any FREs,
>> so that a stack tracer implementation can use this as indication that
>> an outermost frame has been reached and the trace is complete.
>>
>> This representation is backwards compatible, as existing stack tracers
>> should already deal with the case, that an SFrame FDE has a FRE count of
>> zero and stop the trace.

> While representing the construct "DW_CFA_undefined RA" with an SFrame
> FDE with 0 FREs is OK, I think using this as an unambiguous marker for
> outermost frame may be not be
> 
> I think of case when, say, we may need to carry some function-specific
> information in the SFrame FDE, but cannot represent the stack trace
> informtion in SFrame format (for various reasons).  In such a case, we
> may want an SFrame FDE with 0 FREs (with markers on FDE as necessary).
> Yes that implcitly indicates that one cannot stack trace beyond this
> function (as there is no information for stacktracing), but is that
> necessarily the outermost frame? May be not.
> 
> Which is why I think for a stack tracer, using "SFrame FDE with 0 FREs"
> _together_ with a marker like FP is zero on AMD64 and FP/LR are zero on
> AArch64 is still reasonable.  If a similar check is not possible for
> s390x as you point out (although I have a question on that, posted on
> the thread on libc-alpha), an option is to use the spare bit in FDE
> func info to unambiguously mark outermost frame along with an SFrame
> FDE with 0 FREs.

As replied in the other thread on libc-aplha there is no such indication
on s390x (s390 64-bit).  I'll post a V3 of this patch, which introduces
a SFrame FDE infor word flag "ra_undefined".

> Meanwhile this patch below is generally OK. The text in sframe-spec
> will need adjustment, depending on your inputs to above.  Also a nit:
> some test asm files have tab between opcode and operand.

Isn't that the default? At least on s390x that is what I am used to.
The AArch64 cfi-sframe-aarch64-*.s also have a tabs. It appears the
x86-64 cfi-sframe-x86_64-*.s don't.  I can change those to use blanks.

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