]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: reduce alignment for some funcdata symbols
authorCherry Mui <cherryyz@google.com>
Thu, 30 Sep 2021 15:46:00 +0000 (11:46 -0400)
committerCherry Mui <cherryyz@google.com>
Fri, 1 Oct 2021 14:06:36 +0000 (14:06 +0000)
Funcdata like opendefer info and traceback arginfo are varints or
bytes. There is no need to align them.

GC liveness map and inline tree have 32-bit fields, so continue
align them to 4 bytes.

Change-Id: I9d5dd750a926c65a910efe5817f9f5c473019bc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/353469
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/symtab.go

index 8dec78e01746ce0e92a6209144a36b9d2be5eaca..76cca41d25775c1a017a61a82ef85280432d0407 100644 (file)
@@ -537,6 +537,7 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
                        continue
                }
 
+               align := int32(1)
                name := ldr.SymName(s)
                switch {
                case strings.HasPrefix(name, "go.importpath.") && ctxt.UseRelro():
@@ -571,14 +572,17 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
                case strings.HasPrefix(name, "gcargs."),
                        strings.HasPrefix(name, "gclocals."),
                        strings.HasPrefix(name, "gclocals·"),
-                       ldr.SymType(s) == sym.SGOFUNC && s != symgofunc,
-                       strings.HasSuffix(name, ".opendefer"),
+                       ldr.SymType(s) == sym.SGOFUNC && s != symgofunc: // inltree, see pcln.go
+                       // GC stack maps and inltrees have 32-bit fields.
+                       align = 4
+                       fallthrough
+               case strings.HasSuffix(name, ".opendefer"),
                        strings.HasSuffix(name, ".arginfo0"),
                        strings.HasSuffix(name, ".arginfo1"):
+                       // These are just bytes, or varints, use align 1 (set before the switch).
                        symGroupType[s] = sym.SGOFUNC
                        ldr.SetAttrNotInSymbolTable(s, true)
                        ldr.SetCarrierSym(s, symgofunc)
-                       align := int32(4)
                        if a := ldr.SymAlign(s); a < align {
                                ldr.SetSymAlign(s, align)
                        } else {