aboutsummaryrefslogtreecommitdiffstats
path: root/sys/test
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 /sys/test
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 'sys/test')
-rw-r--r--sys/test/32.go19
-rw-r--r--sys/test/64.go19
-rw-r--r--sys/test/test.txt15
3 files changed, 51 insertions, 2 deletions
diff --git a/sys/test/32.go b/sys/test/32.go
index 3a029eba9..c3c56aea7 100644
--- a/sys/test/32.go
+++ b/sys/test/32.go
@@ -116,6 +116,20 @@ var structDescs_32 = []*KeyedStruct{
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "pad", TypeSize: 3}}, IsPad: true},
&ArrayType{TypeCommon: TypeCommon{TypeName: "array", FldName: "f1", IsVarlen: true}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}},
}}},
+ {Key: StructKey{Name: "syz_align7"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "syz_align7", TypeSize: 16}, Fields: []Type{
+ &StructType{Key: StructKey{Name: "syz_align8"}, FldName: "f0"},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f1", TypeSize: 1}}},
+ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "pad", TypeSize: 7}}, IsPad: true},
+ }}},
+ {Key: StructKey{Name: "syz_align8"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "syz_align8", TypeSize: 8}, Fields: []Type{
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f0", TypeSize: 1}, BitfieldLen: 1, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f1", TypeSize: 1}, BitfieldOff: 1, BitfieldLen: 1, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f2", TypeSize: 1}, BitfieldOff: 2, BitfieldLen: 1}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f3", TypeSize: 2}, BitfieldLen: 1, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f4", TypeSize: 2}, BitfieldOff: 1, BitfieldLen: 1, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f5", TypeSize: 2}, BitfieldOff: 2, BitfieldLen: 1}},
+ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "pad", TypeSize: 5}}, IsPad: true},
+ }, AlignAttr: 8}},
{Key: StructKey{Name: "syz_array_blob"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "syz_array_blob", TypeSize: 20}, Fields: []Type{
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f0", TypeSize: 2}}},
&BufferType{TypeCommon: TypeCommon{TypeName: "array", FldName: "f1", TypeSize: 16}, Kind: 1, RangeBegin: 16, RangeEnd: 16},
@@ -490,6 +504,9 @@ var syscalls_32 = []*Syscall{
{Name: "syz_test$align6", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 4}, Type: &StructType{Key: StructKey{Name: "syz_align6"}}},
}},
+ {Name: "syz_test$align7", CallName: "syz_test", Args: []Type{
+ &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 4}, Type: &StructType{Key: StructKey{Name: "syz_align7"}}},
+ }},
{Name: "syz_test$array0", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 4}, Type: &StructType{Key: StructKey{Name: "syz_array_struct"}}},
}},
@@ -722,4 +739,4 @@ var consts_32 = []ConstValue{
{Name: "ONLY_32BITS_CONST", Value: 1},
}
-const revision_32 = "d2a9a5da5971060f9d6e1dfe0ec2a78b9b20d854"
+const revision_32 = "8e3bfbc4dd1f6619b4895bcb80e0004ef4c96928"
diff --git a/sys/test/64.go b/sys/test/64.go
index 246d1c5bc..e97d6156a 100644
--- a/sys/test/64.go
+++ b/sys/test/64.go
@@ -116,6 +116,20 @@ var structDescs_64 = []*KeyedStruct{
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "pad", TypeSize: 3}}, IsPad: true},
&ArrayType{TypeCommon: TypeCommon{TypeName: "array", FldName: "f1", IsVarlen: true}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}},
}}},
+ {Key: StructKey{Name: "syz_align7"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "syz_align7", TypeSize: 16}, Fields: []Type{
+ &StructType{Key: StructKey{Name: "syz_align8"}, FldName: "f0"},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f1", TypeSize: 1}}},
+ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "pad", TypeSize: 7}}, IsPad: true},
+ }}},
+ {Key: StructKey{Name: "syz_align8"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "syz_align8", TypeSize: 8}, Fields: []Type{
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f0", TypeSize: 1}, BitfieldLen: 1, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f1", TypeSize: 1}, BitfieldOff: 1, BitfieldLen: 1, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f2", TypeSize: 1}, BitfieldOff: 2, BitfieldLen: 1}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f3", TypeSize: 2}, BitfieldLen: 1, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f4", TypeSize: 2}, BitfieldOff: 1, BitfieldLen: 1, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f5", TypeSize: 2}, BitfieldOff: 2, BitfieldLen: 1}},
+ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "pad", TypeSize: 5}}, IsPad: true},
+ }, AlignAttr: 8}},
{Key: StructKey{Name: "syz_array_blob"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "syz_array_blob", TypeSize: 20}, Fields: []Type{
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f0", TypeSize: 2}}},
&BufferType{TypeCommon: TypeCommon{TypeName: "array", FldName: "f1", TypeSize: 16}, Kind: 1, RangeBegin: 16, RangeEnd: 16},
@@ -489,6 +503,9 @@ var syscalls_64 = []*Syscall{
{Name: "syz_test$align6", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "syz_align6"}}},
}},
+ {Name: "syz_test$align7", CallName: "syz_test", Args: []Type{
+ &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "syz_align7"}}},
+ }},
{Name: "syz_test$array0", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "syz_array_struct"}}},
}},
@@ -720,4 +737,4 @@ var consts_64 = []ConstValue{
{Name: "IPPROTO_UDP", Value: 17},
}
-const revision_64 = "e12a470f0d2c46ee2f677920db209e6225ce9f38"
+const revision_64 = "4a4abb9774bf056d0952d60f2fffdfdc392353a2"
diff --git a/sys/test/test.txt b/sys/test/test.txt
index d63ed598b..f520afa04 100644
--- a/sys/test/test.txt
+++ b/sys/test/test.txt
@@ -26,6 +26,7 @@ syz_test$align3(a0 ptr[in, syz_align3])
syz_test$align4(a0 ptr[in, syz_align4])
syz_test$align5(a0 ptr[in, syz_align5])
syz_test$align6(a0 ptr[in, syz_align6])
+syz_test$align7(a0 ptr[in, syz_align7])
syz_align0 {
f0 int16
@@ -97,6 +98,20 @@ syz_align6 {
f1 array[int32]
}
+syz_align7 {
+ f0 syz_align8
+ f1 int8
+}
+
+syz_align8 {
+ f0 int8:1
+ f1 int8:1
+ f2 int8:1
+ f3 int16:1
+ f4 int16:1
+ f5 int16:1
+} [packed, align_8]
+
# Structs
syz_test$struct(a0 ptr[in, syz_struct0])