mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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:
parent
2cc347382f
commit
1d10b17589
14 changed files with 102 additions and 275 deletions
|
|
@ -218,9 +218,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
|
|||
Errorf(s, "unknown reloc to %v: %d (%s)", r.Sym.Name, r.Type, sym.RelocName(ctxt.Arch, r.Type))
|
||||
}
|
||||
case objabi.R_TLS_LE:
|
||||
isAndroidX86 := objabi.GOOS == "android" && (ctxt.Arch.InFamily(sys.AMD64, sys.I386))
|
||||
|
||||
if ctxt.LinkMode == LinkExternal && ctxt.IsELF && !isAndroidX86 {
|
||||
if ctxt.LinkMode == LinkExternal && ctxt.IsELF {
|
||||
r.Done = false
|
||||
if r.Sym == nil {
|
||||
r.Sym = ctxt.Tlsg
|
||||
|
|
@ -243,7 +241,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
|
|||
// related to the fact that our own TLS storage happens
|
||||
// to take up 8 bytes.
|
||||
o = 8 + r.Sym.Value
|
||||
} else if ctxt.IsELF || ctxt.HeadType == objabi.Hplan9 || ctxt.HeadType == objabi.Hdarwin || isAndroidX86 {
|
||||
} else if ctxt.IsELF || ctxt.HeadType == objabi.Hplan9 || ctxt.HeadType == objabi.Hdarwin {
|
||||
o = int64(ctxt.Tlsoffset) + r.Add
|
||||
} else if ctxt.HeadType == objabi.Hwindows {
|
||||
o = r.Add
|
||||
|
|
@ -251,9 +249,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
|
|||
log.Fatalf("unexpected R_TLS_LE relocation for %v", ctxt.HeadType)
|
||||
}
|
||||
case objabi.R_TLS_IE:
|
||||
isAndroidX86 := objabi.GOOS == "android" && (ctxt.Arch.InFamily(sys.AMD64, sys.I386))
|
||||
|
||||
if ctxt.LinkMode == LinkExternal && ctxt.IsELF && !isAndroidX86 {
|
||||
if ctxt.LinkMode == LinkExternal && ctxt.IsELF {
|
||||
r.Done = false
|
||||
if r.Sym == nil {
|
||||
r.Sym = ctxt.Tlsg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue