]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: correct the TLS base offset on Android
authorElias Naur <mail@eliasnaur.com>
Mon, 8 Apr 2019 21:12:52 +0000 (23:12 +0200)
committerElias Naur <mail@eliasnaur.com>
Wed, 10 Apr 2019 14:21:20 +0000 (14:21 +0000)
CL 170955 set tlsg to the Android Q free TLS slot offset in the linker
data (16 on amd64, 8 on 386), offsetting all TLS relative access.
We need the 0'th slot (TLS_SLOT_SELF) at initialization, so
compensate with a corresponding negative offset.

Fixes the android/386 and android/amd64 builders broken by CL 170955.

Change-Id: I9882088c0c8bc6a777d2aabc9404cb76f02b6cea
Reviewed-on: https://go-review.googlesource.com/c/go/+/170956
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/runtime/asm_386.s
src/runtime/asm_amd64.s

index 61aae47c08fa8fa3ba6163d7132d28aa5bed44ae..682f1ab5d0b1d499c7b0cded40b8cad46029f7cf 100644 (file)
@@ -172,8 +172,10 @@ nocpuinfo:
        TESTL   AX, AX
        JZ      needtls
 #ifdef GOOS_android
-       MOVL    0(TLS), BX
-       MOVL    BX, 12(SP)      // arg 4: TLS base, stored in the first slot (TLS_SLOT_SELF).
+       // arg 4: TLS base, stored in slot 0 (Android's TLS_SLOT_SELF).
+       // Compensate for tls_g (+8).
+       MOVL    -8(TLS), BX
+       MOVL    BX, 12(SP)
        MOVL    $runtimeĀ·tls_g(SB), 8(SP)      // arg 3: &tls_g
 #else
        MOVL    $0, BX
index 7b2fdf0d3db87187838d105d092c5c7a247130b8..e5b987858ddc1a307366bbfc1142354d9e8a2225 100644 (file)
@@ -136,7 +136,9 @@ nocpuinfo:
        MOVQ    $setg_gcc<>(SB), SI // arg 2: setg_gcc
 #ifdef GOOS_android
        MOVQ    $runtimeĀ·tls_g(SB), DX         // arg 3: &tls_g
-       MOVQ    0(TLS), CX      // arg 4: TLS base, stored in the first slot (TLS_SLOT_SELF).
+       // arg 4: TLS base, stored in slot 0 (Android's TLS_SLOT_SELF).
+       // Compensate for tls_g (+16).
+       MOVQ    -16(TLS), CX
 #else
        MOVQ    $0, DX  // arg 3, 4: not used when using platform's TLS
        MOVQ    $0, CX