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

Peter Bergner bergner@oss.tenstorrent.com
Thu Nov 12 18:55:50 GMT 2026


On 11/11/26 1: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.

I don't see any real problems with clearing s0/fp here, so LGTM.

Reviewed-by: Peter Bergner <bergner@tenstorrent.com>


However, is this something you actually hit?  I ask, because GCC and LLVM
default to -fomit-frame-pointer, including when building GLIBC, so it seems
doubtful you could backtrace using s0/fp all the way through the userspace
call stack to _start.  ...unless you have a specially built userland where
you use -fno-omit-frame-pointer everywhere or have a very short call stack
and are very lucky that nothing uses s0 to hold ordinary values.

Peter




More information about the Libc-alpha mailing list