From 4b042b7d6708cae4cb29fa41b89deea14b2eea32 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 23 Dec 2019 08:46:10 +0100 Subject: sys/linux: fix int64 alignment on 386 Turns out int64 alignment is 4 on 386... But on arm it's still 8. Another amusing finding thanks to syz-check. Update #590 --- pkg/compiler/gen.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'pkg/compiler/gen.go') diff --git a/pkg/compiler/gen.go b/pkg/compiler/gen.go index 631ea5299..03c0f2b0b 100644 --- a/pkg/compiler/gen.go +++ b/pkg/compiler/gen.go @@ -390,15 +390,17 @@ func (comp *compiler) typeAlign(t0 prog.Type) uint64 { default: panic("unknown binary format") } + if prog.IsPad(t0) { + return 1 + } switch t := t0.(type) { - case *prog.IntType, *prog.LenType, *prog.FlagsType, *prog.ProcType, + case *prog.ConstType, *prog.IntType, *prog.LenType, *prog.FlagsType, *prog.ProcType, *prog.CsumType, *prog.PtrType, *prog.VmaType, *prog.ResourceType: - return t0.UnitSize() - case *prog.ConstType: - if t.IsPad { - return 1 + align := t0.UnitSize() + if align == 8 && comp.target.Int64Alignment != 0 { + align = comp.target.Int64Alignment } - return t.UnitSize() + return align case *prog.BufferType: return 1 case *prog.ArrayType: -- cgit mrf-deployment