[PATCH] riscv: Terminate the frame-pointer chain at entry points [BZ #34950]

Jeff Law jeffrey.law@oss.qualcomm.com
Thu Nov 12 16:57:13 GMT 2026



On 11/11/26 12:40 PM, Tommy Chen wrote:
> _start, __thread_start and __thread_start_clone3 do not clear s0, so
> the outermost frame record can link to a stale value instead of NULL.
> The RISC-V psABI requires "The end of the frame record chain is
> indicated by a NULL pointer appearing as the next link in the chain"
> [1].  Frame-pointer unwinders such as perf --call-graph fp follow the
> stale link into unrelated memory.
>
> Clear s0 at the three entry points, as x86_64 (xorl %ebp, %ebp) and
> aarch64 (mov x29, 0) already do in start.S, clone.S and clone3.S.
>
> [1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/main/riscv-cc.adoc#frame-pointer-convention
>
> Signed-off-by: Tommy Chen <gcchen@google.com>
Seems sensible to me.  The only concern I'd have would be that s0 is 
typically callee saved, but in this case we're at the head of the call 
chain and never return, so the fact that we clobber s0 without restoring 
it doesn't seem like a problem.

Deferring to others for the push, I'm slammed right now.

jeff


More information about the Libc-alpha mailing list