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

Indu Bhagat indu.bhagat@oracle.com
Wed Jul 23 03:05:33 GMT 2025


On 7/22/25 9:08 AM, Jens Remus wrote:
> Hello Indu!
> 
> On 22.07.2025 16:31, Jens Remus wrote:
>> 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".
> 
> An attempt to build Glibc with my Binutils patch applied fails due to
> one or more relocation(s) out or range during link.  I guess the .sframe
> merge logic chokes on a FDE without any FREs.
> 
> Please let me know if you gave any guess, where I should start.  I will
> continue tomorrow.
> 

Jens,

Sorry havent been able to debug this one yet.  Will try to find some 
time later tonight..

Indu



More information about the Binutils mailing list