90a3ce02dc25adcf1598faf11a66b151ada3f637.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From 90a3ce02dc25adcf1598faf11a66b151ada3f637 Mon Sep 17 00:00:00 2001
  2. From: Elias Naur <mail@eliasnaur.com>
  3. Date: Wed, 27 Mar 2019 14:25:24 +0100
  4. Subject: [PATCH] cmd/link/internal/ld: skip TLS section on Android
  5. We don't use the TLS section on android, and dropping it avoids
  6. complaints about underalignment from the Android Q linker.
  7. Updates #29674
  8. Change-Id: I91dabf2a58e6eb1783872639a6a144858db09cef
  9. Reviewed-on: https://go-review.googlesource.com/c/go/+/169618
  10. Reviewed-by: Ian Lance Taylor <iant@golang.org>
  11. ---
  12. src/cmd/link/internal/ld/lib.go | 29 +++++++++++++++++------------
  13. 1 file changed, 17 insertions(+), 12 deletions(-)
  14. diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
  15. index 1d44c0eb18b..b331e39fe3e 100644
  16. --- a/src/cmd/link/internal/ld/lib.go
  17. +++ b/src/cmd/link/internal/ld/lib.go
  18. @@ -453,18 +453,23 @@ func (ctxt *Link) loadlib() {
  19. }
  20. }
  21. - tlsg := ctxt.Syms.Lookup("runtime.tlsg", 0)
  22. -
  23. - // runtime.tlsg is used for external linking on platforms that do not define
  24. - // a variable to hold g in assembly (currently only intel).
  25. - if tlsg.Type == 0 {
  26. - tlsg.Type = sym.STLSBSS
  27. - tlsg.Size = int64(ctxt.Arch.PtrSize)
  28. - } else if tlsg.Type != sym.SDYNIMPORT {
  29. - Errorf(nil, "runtime declared tlsg variable %v", tlsg.Type)
  30. - }
  31. - tlsg.Attr |= sym.AttrReachable
  32. - ctxt.Tlsg = tlsg
  33. + // The Android Q linker started to complain about underalignment of the our TLS
  34. + // section. We don't actually use the section on android, so dont't
  35. + // generate it.
  36. + if objabi.GOOS != "android" {
  37. + tlsg := ctxt.Syms.Lookup("runtime.tlsg", 0)
  38. +
  39. + // runtime.tlsg is used for external linking on platforms that do not define
  40. + // a variable to hold g in assembly (currently only intel).
  41. + if tlsg.Type == 0 {
  42. + tlsg.Type = sym.STLSBSS
  43. + tlsg.Size = int64(ctxt.Arch.PtrSize)
  44. + } else if tlsg.Type != sym.SDYNIMPORT {
  45. + Errorf(nil, "runtime declared tlsg variable %v", tlsg.Type)
  46. + }
  47. + tlsg.Attr |= sym.AttrReachable
  48. + ctxt.Tlsg = tlsg
  49. + }
  50. var moduledata *sym.Symbol
  51. if ctxt.BuildMode == BuildModePlugin {