Skip to content

Commit 90a3ce0

Browse files
committed
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/+/169618 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent f24e109 commit 90a3ce0

File tree

1 file changed

+17
-12
lines changed
  • src/cmd/link/internal/ld

1 file changed

+17
-12
lines changed

src/cmd/link/internal/ld/lib.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -453,18 +453,23 @@ func (ctxt *Link) loadlib() {
453453
}
454454
}
455455

456-
tlsg := ctxt.Syms.Lookup("runtime.tlsg", 0)
457-
458-
// runtime.tlsg is used for external linking on platforms that do not define
459-
// a variable to hold g in assembly (currently only intel).
460-
if tlsg.Type == 0 {
461-
tlsg.Type = sym.STLSBSS
462-
tlsg.Size = int64(ctxt.Arch.PtrSize)
463-
} else if tlsg.Type != sym.SDYNIMPORT {
464-
Errorf(nil, "runtime declared tlsg variable %v", tlsg.Type)
465-
}
466-
tlsg.Attr |= sym.AttrReachable
467-
ctxt.Tlsg = tlsg
456+
// The Android Q linker started to complain about underalignment of the our TLS
457+
// section. We don't actually use the section on android, so dont't
458+
// generate it.
459+
if objabi.GOOS != "android" {
460+
tlsg := ctxt.Syms.Lookup("runtime.tlsg", 0)
461+
462+
// runtime.tlsg is used for external linking on platforms that do not define
463+
// a variable to hold g in assembly (currently only intel).
464+
if tlsg.Type == 0 {
465+
tlsg.Type = sym.STLSBSS
466+
tlsg.Size = int64(ctxt.Arch.PtrSize)
467+
} else if tlsg.Type != sym.SDYNIMPORT {
468+
Errorf(nil, "runtime declared tlsg variable %v", tlsg.Type)
469+
}
470+
tlsg.Attr |= sym.AttrReachable
471+
ctxt.Tlsg = tlsg
472+
}
468473

469474
var moduledata *sym.Symbol
470475
if ctxt.BuildMode == BuildModePlugin {

0 commit comments

Comments
 (0)