cmd/link/ld,cmd/internal/obj,runtime: make the Android TLS offset dynamic

We're going to need a different TLS offset for Android Q, so the static
offsets used for 386 and amd64 are no longer viable on Android.

Introduce runtime·tls_g and use that for indexing into TLS storage. As
an added benefit, we can then merge the TLS setup code for all android
GOARCHs.

While we're at it, remove a bunch of android special cases no longer
needed.

Updates #29674
Updates #29249 (perhaps fixes it)

Change-Id: I77c7385aec7de8f1f6a4da7c9c79999157e39572
Reviewed-on: https://go-review.googlesource.com/c/go/+/169817
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Elias Naur 2019-03-28 13:11:53 +01:00
parent 2cc347382f
commit 1d10b17589
14 changed files with 102 additions and 275 deletions

View file

@ -13,11 +13,11 @@
static void* threadentry(void*);
static void (*setg_gcc)(void*);
// This will be set in gcc_android_amd64.c for android-specific customization.
void (*x_cgo_inittls)(void);
// This will be set in gcc_android.c for android-specific customization.
void (*x_cgo_inittls)(void **tlsg, void **tlsbase);
void
x_cgo_init(G* g, void (*setg)(void*))
x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase)
{
pthread_attr_t *attr;
size_t size;
@ -49,7 +49,7 @@ x_cgo_init(G* g, void (*setg)(void*))
free(attr);
if (x_cgo_inittls) {
x_cgo_inittls();
x_cgo_inittls(tlsg, tlsbase);
}
}