Skip to content

Commit c2c76c6

Browse files
committed
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 <[email protected]> Run-TryBot: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 36147dd commit c2c76c6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,16 +475,19 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
475475
s = ldr.CreateSymForUpdate("type.*", 0)
476476
s.SetType(sym.STYPE)
477477
s.SetSize(0)
478+
s.SetAlign(int32(ctxt.Arch.PtrSize))
478479
symtype = s.Sym()
479480

480481
s = ldr.CreateSymForUpdate("typerel.*", 0)
481482
s.SetType(sym.STYPERELRO)
482483
s.SetSize(0)
484+
s.SetAlign(int32(ctxt.Arch.PtrSize))
483485
symtyperel = s.Sym()
484486
} else {
485487
s = ldr.CreateSymForUpdate("type.*", 0)
486488
s.SetType(sym.STYPE)
487489
s.SetSize(0)
490+
s.SetAlign(int32(ctxt.Arch.PtrSize))
488491
symtype = s.Sym()
489492
symtyperel = s.Sym()
490493
}
@@ -496,6 +499,7 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
496499
s := ldr.CreateSymForUpdate(name, 0)
497500
s.SetType(t)
498501
s.SetSize(0)
502+
s.SetAlign(int32(ctxt.Arch.PtrSize))
499503
s.SetLocal(true)
500504
setCarrierSym(t, s.Sym())
501505
return s.Sym()

0 commit comments

Comments
 (0)