From 3ca39dfc4dd8a2dda5b3a9b8c29e295839490af3 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 29 Sep 2016 13:28:03 +0200 Subject: sys: add padding to structs again Struct padding was accidentially lost after: 852e3d2eae98a913b7ec91822ba4dc61059a6955 Restore it. Now with tests. Fixes #78 --- prog/encodingexec_test.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'prog') diff --git a/prog/encodingexec_test.go b/prog/encodingexec_test.go index 651352fd6..eddda5199 100644 --- a/prog/encodingexec_test.go +++ b/prog/encodingexec_test.go @@ -67,15 +67,26 @@ func TestSerializeForExec(t *testing.T) { }, }, { - // TODO: the offsets are currently caclulated incorrectly. "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, + 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$align0"), 1, argConst, ptrSize, dataOffset, + callID("syz_test$align1"), 1, argConst, ptrSize, dataOffset, instrEOF, }, }, @@ -88,6 +99,17 @@ func TestSerializeForExec(t *testing.T) { 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, + instrEOF, + }, + }, } for i, test := range tests { -- cgit mrf-deployment