From c2c76c6f198480f3c9aece4aa5d9b8de044d8457 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Tue, 14 Jun 2022 16:47:57 -0400 Subject: [PATCH] cmd/link: set alignment for carrier symbols For carrier symbols like type.*, currently we don't set its alignment. Normally it doesn't actually matter as we still align the inner symbols. But in some cases it does make the symbol table a bit weird, e.g. on darwin/arm64, 0000000000070000 s _runtime.types 0000000000070001 s _type.* The address of the symbol _type.* is a bit weird. And the new darwin linker from Xcode 14 beta doesn't like that (see issue 53372). This CL aligns them. Fixes #53372. Change-Id: I1cb19dcf172e9a6bca248d85a7e54da76cbbc8a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/411912 Reviewed-by: Than McIntosh Run-TryBot: Cherry Mui TryBot-Result: Gopher Robot --- src/cmd/link/internal/ld/symtab.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index cc6a2c0e10..ee963bc366 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -475,16 +475,19 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind { s = ldr.CreateSymForUpdate("type.*", 0) s.SetType(sym.STYPE) s.SetSize(0) + s.SetAlign(int32(ctxt.Arch.PtrSize)) symtype = s.Sym() s = ldr.CreateSymForUpdate("typerel.*", 0) s.SetType(sym.STYPERELRO) s.SetSize(0) + s.SetAlign(int32(ctxt.Arch.PtrSize)) symtyperel = s.Sym() } else { s = ldr.CreateSymForUpdate("type.*", 0) s.SetType(sym.STYPE) s.SetSize(0) + s.SetAlign(int32(ctxt.Arch.PtrSize)) symtype = s.Sym() symtyperel = s.Sym() } @@ -496,6 +499,7 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind { s := ldr.CreateSymForUpdate(name, 0) s.SetType(t) s.SetSize(0) + s.SetAlign(int32(ctxt.Arch.PtrSize)) s.SetLocal(true) setCarrierSym(t, s.Sym()) return s.Sym() -- 2.48.1