cmd/link: reduce alignment for some funcdata symbols

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>
This commit is contained in:
Cherry Mui 2021-09-30 11:46:00 -04:00
parent 8ac5cbe05d
commit 96d3ba868a
1 changed files with 7 additions and 3 deletions

View 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 {