aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/compiler/gen.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/pkg/compiler/gen.go b/pkg/compiler/gen.go
index 62c36b735..b570c138b 100644
--- a/pkg/compiler/gen.go
+++ b/pkg/compiler/gen.go
@@ -276,9 +276,7 @@ func (comp *compiler) addAlignment(fields []sys.Type, varlen, packed bool, align
}
return newFields
}
- var off uint64
- // TODO(dvyukov): this is wrong: if alignAttr!=0, we must use it, not max
- align := alignAttr
+ var align, off uint64
for i, f := range fields {
if i > 0 && !fields[i-1].BitfieldMiddle() {
a := comp.typeAlign(f)
@@ -300,6 +298,9 @@ func (comp *compiler) addAlignment(fields []sys.Type, varlen, packed bool, align
off += f.Size()
}
}
+ if alignAttr != 0 {
+ align = alignAttr
+ }
if align != 0 && off%align != 0 && !varlen {
pad := align - off%align
off += pad