]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: not mark save_g NOFRAME on ARM
authorCherry Mui <cherryyz@google.com>
Tue, 10 May 2022 20:09:54 +0000 (16:09 -0400)
committerCherry Mui <cherryyz@google.com>
Tue, 10 May 2022 20:38:07 +0000 (20:38 +0000)
On ARM, when GOARM<=6 the TLS pointer is fetched via a call to a
kernel helper. This call clobbers LR, even just temporarily. If
the function is NOFRAME, if a profiling signal lands right after
the call returns, the unwinder will find the wrong LR. Not mark it
NOFRAME, so the LR will be saved in the usual way and stack
unwinding should work.

May fix #52829.

Change-Id: I419a31dcf4afbcff8d7ab8f179eec3c477589e60
Reviewed-on: https://go-review.googlesource.com/c/go/+/405482
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

src/runtime/tls_arm.s

index 83fd37e6ecb4fa8d74898023e376e4e5b6d68b85..d224c5545204df25e429fc146e3b832655fed1e2 100644 (file)
 // NOTE: runtime.gogo assumes that R1 is preserved by this function.
 //       runtime.mcall assumes this function only clobbers R0 and R11.
 // Returns with g in R0.
-TEXT runtime·save_g(SB),NOSPLIT|NOFRAME,$0
+TEXT runtime·save_g(SB),NOSPLIT,$0
        // If the host does not support MRC the linker will replace it with
        // a call to runtime.read_tls_fallback which jumps to __kuser_get_tls.
        // The replacement function saves LR in R11 over the call to read_tls_fallback.
+       // To make stack unwinding work, this function should NOT be marked as NOFRAME,
+       // as it may contain a call, which clobbers LR even just temporarily.
        MRC     15, 0, R0, C13, C0, 3 // fetch TLS base pointer
        BIC $3, R0 // Darwin/ARM might return unaligned pointer
        MOVW    runtime·tls_g(SB), R11