]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link/internal/ld: skip TLS section on Android
authorElias Naur <mail@eliasnaur.com>
Wed, 27 Mar 2019 13:25:24 +0000 (14:25 +0100)
committerElias Naur <mail@eliasnaur.com>
Wed, 27 Mar 2019 14:46:21 +0000 (14:46 +0000)
We don't use the TLS section on android, and dropping it avoids
complaints about underalignment from the Android Q linker.

Updates #29674

Change-Id: I91dabf2a58e6eb1783872639a6a144858db09cef
Reviewed-on: https://go-review.googlesource.com/c/go/+/169618
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/link/internal/ld/lib.go

index 1d44c0eb18b68213e9998c79120f566d4dd15bbf..b331e39fe3e896fd1122bdcb9746c751139bdc20 100644 (file)
@@ -453,18 +453,23 @@ func (ctxt *Link) loadlib() {
                }
        }
 
-       tlsg := ctxt.Syms.Lookup("runtime.tlsg", 0)
-
-       // runtime.tlsg is used for external linking on platforms that do not define
-       // a variable to hold g in assembly (currently only intel).
-       if tlsg.Type == 0 {
-               tlsg.Type = sym.STLSBSS
-               tlsg.Size = int64(ctxt.Arch.PtrSize)
-       } else if tlsg.Type != sym.SDYNIMPORT {
-               Errorf(nil, "runtime declared tlsg variable %v", tlsg.Type)
-       }
-       tlsg.Attr |= sym.AttrReachable
-       ctxt.Tlsg = tlsg
+       // The Android Q linker started to complain about underalignment of the our TLS
+       // section. We don't actually use the section on android, so dont't
+       // generate it.
+       if objabi.GOOS != "android" {
+               tlsg := ctxt.Syms.Lookup("runtime.tlsg", 0)
+
+               // runtime.tlsg is used for external linking on platforms that do not define
+               // a variable to hold g in assembly (currently only intel).
+               if tlsg.Type == 0 {
+                       tlsg.Type = sym.STLSBSS
+                       tlsg.Size = int64(ctxt.Arch.PtrSize)
+               } else if tlsg.Type != sym.SDYNIMPORT {
+                       Errorf(nil, "runtime declared tlsg variable %v", tlsg.Type)
+               }
+               tlsg.Attr |= sym.AttrReachable
+               ctxt.Tlsg = tlsg
+       }
 
        var moduledata *sym.Symbol
        if ctxt.BuildMode == BuildModePlugin {