aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler/gen.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-02-25 14:44:29 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-02-25 14:44:29 +0100
commit2145057cb8a50aba1a27a67be19953bee9b164fd (patch)
treea8a5b759ef44ad1a88f1bf3064283ff3caa7fc69 /pkg/compiler/gen.go
parent1f4ae3f41357cf0a8cf8c698cbcd1000b8b44bf4 (diff)
pkg/compiler: fix alignment corner case
Fix alignemnt calculation for packed structs with alignment and bitfields. Amusingly this affected only a single real struct -- ipv6_fragment_ext_header.
Diffstat (limited to 'pkg/compiler/gen.go')
-rw-r--r--pkg/compiler/gen.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/pkg/compiler/gen.go b/pkg/compiler/gen.go
index 7f0701ed7..ddcec2252 100644
--- a/pkg/compiler/gen.go
+++ b/pkg/compiler/gen.go
@@ -252,7 +252,9 @@ func (comp *compiler) addAlignment(fields []prog.Type, varlen, packed bool, alig
if !varlen && alignAttr != 0 {
size := uint64(0)
for _, f := range fields {
- size += f.Size()
+ if !f.BitfieldMiddle() {
+ size += f.Size()
+ }
}
if tail := size % alignAttr; tail != 0 {
newFields = append(newFields, genPad(alignAttr-tail))