diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2019-12-23 08:46:10 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-12-23 08:57:42 +0100 |
| commit | 4b042b7d6708cae4cb29fa41b89deea14b2eea32 (patch) | |
| tree | e624c19095860d2901d0a9094b7269a6c31e79d7 /pkg | |
| parent | 61f4e7ee54a1a1ae938c8ab2ee18bf16da1abab4 (diff) | |
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
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/compiler/gen.go | 14 |
1 files changed, 8 insertions, 6 deletions
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: |
