From 404899f6b56800c1d8e0521fc9ce0c856e459d94 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Sat, 24 Oct 2020 13:05:31 -0400 Subject: [PATCH] cmd/link: preserve alignment for stackmap symbols Stackmap symbols are content-addressable, so it may be dedup'd with another symbol with same content. We want stackmap symbols 4-byte aligned. But if it dedup's with another symbol with larger alignment, preserve that alignment. Fixes #42071. Change-Id: I1616dd2b0c175b2aac8f68782a5c7a62053c0b57 Reviewed-on: https://go-review.googlesource.com/c/go/+/264897 Trust: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Go Bot Reviewed-by: Joel Sing Reviewed-by: Than McIntosh --- src/cmd/link/internal/ld/symtab.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index dd82963a41..ca688e2011 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -580,8 +580,12 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind { symGroupType[s] = sym.SGOFUNC ldr.SetAttrNotInSymbolTable(s, true) ldr.SetCarrierSym(s, symgofunc) - const align = 4 - ldr.SetSymAlign(s, align) + align := int32(4) + if a := ldr.SymAlign(s); a < align { + ldr.SetSymAlign(s, align) + } else { + align = a + } liveness += (ldr.SymSize(s) + int64(align) - 1) &^ (int64(align) - 1) } } -- 2.51.0