From 54e0cede4384b7c1655f9183577bfccc11d9a7d5 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Tue, 10 Jan 2017 16:45:52 +0100 Subject: prog: add bitfields to templates Now it's possible to use `int32:18` to denote a bitfield of size 18 as a struct field. This fixes #72. --- prog/encodingexec_test.go | 87 +++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 36 deletions(-) (limited to 'prog/encodingexec_test.go') diff --git a/prog/encodingexec_test.go b/prog/encodingexec_test.go index d16a6f1e2..25960b338 100644 --- a/prog/encodingexec_test.go +++ b/prog/encodingexec_test.go @@ -62,92 +62,107 @@ func TestSerializeForExec(t *testing.T) { { "syz_test$int(0x1, 0x2, 0x3, 0x4, 0x5)", []uint64{ - callID("syz_test$int"), 5, argConst, 8, 1, argConst, 1, 2, argConst, 2, 3, argConst, 4, 4, argConst, 8, 5, + callID("syz_test$int"), 5, argConst, 8, 1, 0, 0, argConst, 1, 2, 0, 0, argConst, 2, 3, 0, 0, argConst, 4, 4, 0, 0, argConst, 8, 5, 0, 0, instrEOF, }, }, { "syz_test$align0(&(0x7f0000000000)={0x1, 0x2, 0x3, 0x4, 0x5})", []uint64{ - instrCopyin, dataOffset + 0, argConst, 2, 1, - instrCopyin, dataOffset + 4, argConst, 4, 2, - instrCopyin, dataOffset + 8, argConst, 1, 3, - instrCopyin, dataOffset + 10, argConst, 2, 4, - instrCopyin, dataOffset + 16, argConst, 8, 5, - callID("syz_test$align0"), 1, argConst, ptrSize, dataOffset, + instrCopyin, dataOffset + 0, argConst, 2, 1, 0, 0, + instrCopyin, dataOffset + 4, argConst, 4, 2, 0, 0, + instrCopyin, dataOffset + 8, argConst, 1, 3, 0, 0, + instrCopyin, dataOffset + 10, argConst, 2, 4, 0, 0, + instrCopyin, dataOffset + 16, argConst, 8, 5, 0, 0, + callID("syz_test$align0"), 1, argConst, ptrSize, dataOffset, 0, 0, instrEOF, }, }, { "syz_test$align1(&(0x7f0000000000)={0x1, 0x2, 0x3, 0x4, 0x5})", []uint64{ - instrCopyin, dataOffset + 0, argConst, 2, 1, - instrCopyin, dataOffset + 2, argConst, 4, 2, - instrCopyin, dataOffset + 6, argConst, 1, 3, - instrCopyin, dataOffset + 7, argConst, 2, 4, - instrCopyin, dataOffset + 9, argConst, 8, 5, - callID("syz_test$align1"), 1, argConst, ptrSize, dataOffset, + instrCopyin, dataOffset + 0, argConst, 2, 1, 0, 0, + instrCopyin, dataOffset + 2, argConst, 4, 2, 0, 0, + instrCopyin, dataOffset + 6, argConst, 1, 3, 0, 0, + instrCopyin, dataOffset + 7, argConst, 2, 4, 0, 0, + instrCopyin, dataOffset + 9, argConst, 8, 5, 0, 0, + callID("syz_test$align1"), 1, argConst, ptrSize, dataOffset, 0, 0, instrEOF, }, }, { "syz_test$union0(&(0x7f0000000000)={0x1, @f2=0x2})", []uint64{ - instrCopyin, dataOffset + 0, argConst, 8, 1, - instrCopyin, dataOffset + 8, argConst, 1, 2, - callID("syz_test$union0"), 1, argConst, ptrSize, dataOffset, + instrCopyin, dataOffset + 0, argConst, 8, 1, 0, 0, + instrCopyin, dataOffset + 8, argConst, 1, 2, 0, 0, + callID("syz_test$union0"), 1, argConst, ptrSize, dataOffset, 0, 0, instrEOF, }, }, { "syz_test$array0(&(0x7f0000000000)={0x1, [@f0=0x2, @f1=0x3], 0x4})", []uint64{ - instrCopyin, dataOffset + 0, argConst, 1, 1, - instrCopyin, dataOffset + 1, argConst, 2, 2, - instrCopyin, dataOffset + 3, argConst, 8, 3, - instrCopyin, dataOffset + 11, argConst, 8, 4, - callID("syz_test$array0"), 1, argConst, ptrSize, dataOffset, + instrCopyin, dataOffset + 0, argConst, 1, 1, 0, 0, + instrCopyin, dataOffset + 1, argConst, 2, 2, 0, 0, + instrCopyin, dataOffset + 3, argConst, 8, 3, 0, 0, + instrCopyin, dataOffset + 11, argConst, 8, 4, 0, 0, + callID("syz_test$array0"), 1, argConst, ptrSize, dataOffset, 0, 0, instrEOF, }, }, { "syz_test$array1(&(0x7f0000000000)={0x42, \"0102030405\"})", []uint64{ - instrCopyin, dataOffset + 0, argConst, 1, 0x42, + instrCopyin, dataOffset + 0, argConst, 1, 0x42, 0, 0, instrCopyin, dataOffset + 1, argData, 5, 0x0504030201, - callID("syz_test$array1"), 1, argConst, ptrSize, dataOffset, + callID("syz_test$array1"), 1, argConst, ptrSize, dataOffset, 0, 0, instrEOF, }, }, { "syz_test$array2(&(0x7f0000000000)={0x42, \"aaaaaaaabbbbbbbbccccccccdddddddd\", 0x43})", []uint64{ - instrCopyin, dataOffset + 0, argConst, 2, 0x42, + instrCopyin, dataOffset + 0, argConst, 2, 0x42, 0, 0, instrCopyin, dataOffset + 2, argData, 16, 0xbbbbbbbbaaaaaaaa, 0xddddddddcccccccc, - instrCopyin, dataOffset + 18, argConst, 2, 0x43, - callID("syz_test$array2"), 1, argConst, ptrSize, dataOffset, + instrCopyin, dataOffset + 18, argConst, 2, 0x43, 0, 0, + callID("syz_test$array2"), 1, argConst, ptrSize, dataOffset, 0, 0, instrEOF, }, }, { "syz_test$end0(&(0x7f0000000000)={0x42, 0x42, 0x42, 0x42, 0x42})", []uint64{ - instrCopyin, dataOffset + 0, argConst, 1, 0x42, - instrCopyin, dataOffset + 1, argConst, 2, 0x4200, - instrCopyin, dataOffset + 3, argConst, 4, 0x42000000, - instrCopyin, dataOffset + 7, argConst, 8, 0x4200000000000000, - instrCopyin, dataOffset + 15, argConst, 8, 0x4200000000000000, - callID("syz_test$end0"), 1, argConst, ptrSize, dataOffset, + instrCopyin, dataOffset + 0, argConst, 1, 0x42, 0, 0, + instrCopyin, dataOffset + 1, argConst, 2, 0x4200, 0, 0, + instrCopyin, dataOffset + 3, argConst, 4, 0x42000000, 0, 0, + instrCopyin, dataOffset + 7, argConst, 8, 0x4200000000000000, 0, 0, + instrCopyin, dataOffset + 15, argConst, 8, 0x4200000000000000, 0, 0, + callID("syz_test$end0"), 1, argConst, ptrSize, dataOffset, 0, 0, instrEOF, }, }, { "syz_test$end1(&(0x7f0000000000)={0xe, 0x42, 0x1})", []uint64{ - instrCopyin, dataOffset + 0, argConst, 2, 0x0e00, - instrCopyin, dataOffset + 2, argConst, 4, 0x42000000, - instrCopyin, dataOffset + 6, argConst, 8, 0x0100000000000000, - callID("syz_test$end1"), 1, argConst, ptrSize, dataOffset, + instrCopyin, dataOffset + 0, argConst, 2, 0x0e00, 0, 0, + instrCopyin, dataOffset + 2, argConst, 4, 0x42000000, 0, 0, + instrCopyin, dataOffset + 6, argConst, 8, 0x0100000000000000, 0, 0, + callID("syz_test$end1"), 1, argConst, ptrSize, dataOffset, 0, 0, + instrEOF, + }, + }, + { + "syz_test$bf(&(0x7f0000000000)={0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42})", + []uint64{ + instrCopyin, dataOffset + 0, argConst, 2, 0x42, 0, 10, + instrCopyin, dataOffset + 8, argConst, 8, 0x42, 0, 0, + instrCopyin, dataOffset + 16, argConst, 2, 0x42, 0, 5, + instrCopyin, dataOffset + 16, argConst, 2, 0x42, 5, 6, + instrCopyin, dataOffset + 20, argConst, 4, 0x42, 0, 15, + instrCopyin, dataOffset + 24, argConst, 2, 0x42, 0, 11, + instrCopyin, dataOffset + 26, argConst, 2, 0x4200, 0, 11, + instrCopyin, dataOffset + 28, argConst, 1, 0x42, 0, 0, + callID("syz_test$bf"), 1, argConst, ptrSize, dataOffset, 0, 0, instrEOF, }, }, -- cgit mrf-deployment