Commit 90a3ce02 authored by Elias Naur's avatar Elias Naur

cmd/link/internal/ld: skip TLS section on Android

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/+/169618Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent f24e1099
...@@ -453,18 +453,23 @@ func (ctxt *Link) loadlib() { ...@@ -453,18 +453,23 @@ func (ctxt *Link) loadlib() {
} }
} }
tlsg := ctxt.Syms.Lookup("runtime.tlsg", 0) // 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
// runtime.tlsg is used for external linking on platforms that do not define // generate it.
// a variable to hold g in assembly (currently only intel). if objabi.GOOS != "android" {
if tlsg.Type == 0 { tlsg := ctxt.Syms.Lookup("runtime.tlsg", 0)
tlsg.Type = sym.STLSBSS
tlsg.Size = int64(ctxt.Arch.PtrSize) // runtime.tlsg is used for external linking on platforms that do not define
} else if tlsg.Type != sym.SDYNIMPORT { // a variable to hold g in assembly (currently only intel).
Errorf(nil, "runtime declared tlsg variable %v", tlsg.Type) if tlsg.Type == 0 {
} tlsg.Type = sym.STLSBSS
tlsg.Attr |= sym.AttrReachable tlsg.Size = int64(ctxt.Arch.PtrSize)
ctxt.Tlsg = tlsg } 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 var moduledata *sym.Symbol
if ctxt.BuildMode == BuildModePlugin { if ctxt.BuildMode == BuildModePlugin {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment