]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: set alignment for carrier symbols
authorCherry Mui <cherryyz@google.com>
Tue, 14 Jun 2022 20:47:57 +0000 (16:47 -0400)
committerCherry Mui <cherryyz@google.com>
Wed, 15 Jun 2022 17:37:53 +0000 (17:37 +0000)
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 <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

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

index cc6a2c0e10714a6f3843c1108df34d966d8fee34..ee963bc366bdac2cdbc7e545b3dd0c027177f897 100644 (file)
@@ -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()