aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encodingexec_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-04-15 12:36:31 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-04-15 13:23:33 +0000
commitb6f969371dc1e824c76636c0d3754a91b55d69b9 (patch)
tree92dd3d2c06c03a9247b0da72c1f962841f5dd81d /prog/encodingexec_test.go
parentf887b0490140a0c80dd49d2c549ac57ac2adc2b9 (diff)
prog: more compact exec encoding for addresses
1. Don't write size/flags for addresses. 2. Write address w/o data offset (fewer bytes in leb128 encoding). Median exec size shrinks by 25%: - exec sizes: 10%:584 50%:1423 90%:7076 + exec sizes: 10%:448 50%:1065 90%:6319
Diffstat (limited to 'prog/encodingexec_test.go')
-rw-r--r--prog/encodingexec_test.go349
1 files changed, 246 insertions, 103 deletions
diff --git a/prog/encodingexec_test.go b/prog/encodingexec_test.go
index 19b7d1761..1b34f4cab 100644
--- a/prog/encodingexec_test.go
+++ b/prog/encodingexec_test.go
@@ -88,12 +88,12 @@ func TestSerializeForExec(t *testing.T) {
{
"test$align0(&(0x7f0000000000)={0x1, 0x2, 0x3, 0x4, 0x5})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 2, 1,
- execInstrCopyin, dataOffset + 4, execArgConst, 4, 2,
- execInstrCopyin, dataOffset + 8, execArgConst, 1, 3,
- execInstrCopyin, dataOffset + 10, execArgConst, 2, 4,
- execInstrCopyin, dataOffset + 16, execArgConst, 8, 5,
- callID("test$align0"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 2, 1,
+ execInstrCopyin, 4, execArgConst, 4, 2,
+ execInstrCopyin, 8, execArgConst, 1, 3,
+ execInstrCopyin, 10, execArgConst, 2, 4,
+ execInstrCopyin, 16, execArgConst, 8, 5,
+ callID("test$align0"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -101,12 +101,12 @@ func TestSerializeForExec(t *testing.T) {
{
"test$align1(&(0x7f0000000000)={0x1, 0x2, 0x3, 0x4, 0x5})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 2, 1,
- execInstrCopyin, dataOffset + 2, execArgConst, 4, 2,
- execInstrCopyin, dataOffset + 6, execArgConst, 1, 3,
- execInstrCopyin, dataOffset + 7, execArgConst, 2, 4,
- execInstrCopyin, dataOffset + 9, execArgConst, 8, 5,
- callID("test$align1"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 2, 1,
+ execInstrCopyin, 2, execArgConst, 4, 2,
+ execInstrCopyin, 6, execArgConst, 1, 3,
+ execInstrCopyin, 7, execArgConst, 2, 4,
+ execInstrCopyin, 9, execArgConst, 8, 5,
+ callID("test$align1"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -114,10 +114,10 @@ func TestSerializeForExec(t *testing.T) {
{
"test$align2(&(0x7f0000000000)={0x42, {[0x43]}, {[0x44]}})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 1, 0x42,
- execInstrCopyin, dataOffset + 1, execArgConst, 2, 0x43,
- execInstrCopyin, dataOffset + 4, execArgConst, 2, 0x44,
- callID("test$align2"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 1, 0x42,
+ execInstrCopyin, 1, execArgConst, 2, 0x43,
+ execInstrCopyin, 4, execArgConst, 2, 0x44,
+ callID("test$align2"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -125,10 +125,10 @@ func TestSerializeForExec(t *testing.T) {
{
"test$align3(&(0x7f0000000000)={0x42, {0x43}, {0x44}})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 1, 0x42,
- execInstrCopyin, dataOffset + 1, execArgConst, 1, 0x43,
- execInstrCopyin, dataOffset + 4, execArgConst, 1, 0x44,
- callID("test$align3"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 1, 0x42,
+ execInstrCopyin, 1, execArgConst, 1, 0x43,
+ execInstrCopyin, 4, execArgConst, 1, 0x44,
+ callID("test$align3"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -136,10 +136,10 @@ func TestSerializeForExec(t *testing.T) {
{
"test$align4(&(0x7f0000000000)={{0x42, 0x43}, 0x44})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 1, 0x42,
- execInstrCopyin, dataOffset + 1, execArgConst, 2, 0x43,
- execInstrCopyin, dataOffset + 4, execArgConst, 1, 0x44,
- callID("test$align4"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 1, 0x42,
+ execInstrCopyin, 1, execArgConst, 2, 0x43,
+ execInstrCopyin, 4, execArgConst, 1, 0x44,
+ callID("test$align4"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -147,13 +147,13 @@ func TestSerializeForExec(t *testing.T) {
{
"test$align5(&(0x7f0000000000)={{0x42, []}, {0x43, [0x44, 0x45, 0x46]}, 0x47})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 8, 0x42,
- execInstrCopyin, dataOffset + 8, execArgConst, 8, 0x43,
- execInstrCopyin, dataOffset + 16, execArgConst, 2, 0x44,
- execInstrCopyin, dataOffset + 18, execArgConst, 2, 0x45,
- execInstrCopyin, dataOffset + 20, execArgConst, 2, 0x46,
- execInstrCopyin, dataOffset + 22, execArgConst, 1, 0x47,
- callID("test$align5"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 8, 0x42,
+ execInstrCopyin, 8, execArgConst, 8, 0x43,
+ execInstrCopyin, 16, execArgConst, 2, 0x44,
+ execInstrCopyin, 18, execArgConst, 2, 0x45,
+ execInstrCopyin, 20, execArgConst, 2, 0x46,
+ execInstrCopyin, 22, execArgConst, 1, 0x47,
+ callID("test$align5"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -161,9 +161,9 @@ func TestSerializeForExec(t *testing.T) {
{
"test$align6(&(0x7f0000000000)={0x42, [0x43]})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 1, 0x42,
- execInstrCopyin, dataOffset + 4, execArgConst, 4, 0x43,
- callID("test$align6"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 1, 0x42,
+ execInstrCopyin, 4, execArgConst, 4, 0x43,
+ callID("test$align6"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -171,9 +171,9 @@ func TestSerializeForExec(t *testing.T) {
{
"test$union0(&(0x7f0000000000)={0x1, @f2=0x2})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 8, 1,
- execInstrCopyin, dataOffset + 8, execArgConst, 1, 2,
- callID("test$union0"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 8, 1,
+ execInstrCopyin, 8, execArgConst, 1, 2,
+ callID("test$union0"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -181,9 +181,9 @@ func TestSerializeForExec(t *testing.T) {
{
"test$union1(&(0x7f0000000000)={@f1=0x42, 0x43})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 4, 0x42,
- execInstrCopyin, dataOffset + 8, execArgConst, 1, 0x43,
- callID("test$union1"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 4, 0x42,
+ execInstrCopyin, 8, execArgConst, 1, 0x43,
+ callID("test$union1"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -191,9 +191,9 @@ func TestSerializeForExec(t *testing.T) {
{
"test$union2(&(0x7f0000000000)={@f1=0x42, 0x43})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 4, 0x42,
- execInstrCopyin, dataOffset + 4, execArgConst, 1, 0x43,
- callID("test$union2"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 4, 0x42,
+ execInstrCopyin, 4, execArgConst, 1, 0x43,
+ callID("test$union2"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -201,11 +201,11 @@ func TestSerializeForExec(t *testing.T) {
{
"test$array0(&(0x7f0000000000)={0x1, [@f0=0x2, @f1=0x3], 0x4})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 1, 1,
- execInstrCopyin, dataOffset + 1, execArgConst, 2, 2,
- execInstrCopyin, dataOffset + 3, execArgConst, 8, 3,
- execInstrCopyin, dataOffset + 11, execArgConst, 8, 4,
- callID("test$array0"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 1, 1,
+ execInstrCopyin, 1, execArgConst, 2, 2,
+ execInstrCopyin, 3, execArgConst, 8, 3,
+ execInstrCopyin, 11, execArgConst, 8, 4,
+ callID("test$array0"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -213,9 +213,9 @@ func TestSerializeForExec(t *testing.T) {
{
"test$array1(&(0x7f0000000000)={0x42, \"0102030405\"})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 1, 0x42,
- execInstrCopyin, dataOffset + 1, execArgData, 5, []byte{0x01, 0x02, 0x03, 0x04, 0x05},
- callID("test$array1"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 1, 0x42,
+ execInstrCopyin, 1, execArgData, 5, []byte{0x01, 0x02, 0x03, 0x04, 0x05},
+ callID("test$array1"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -223,15 +223,15 @@ func TestSerializeForExec(t *testing.T) {
{
"test$array2(&(0x7f0000000000)={0x42, \"aaaaaaaabbbbbbbbccccccccdddddddd\", 0x43})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 2, 0x42,
- execInstrCopyin, dataOffset + 2, execArgData, 16, []byte{
+ execInstrCopyin, 0, execArgConst, 2, 0x42,
+ execInstrCopyin, 2, execArgData, 16, []byte{
0xaa, 0xaa, 0xaa, 0xaa,
0xbb, 0xbb, 0xbb, 0xbb,
0xcc, 0xcc, 0xcc, 0xcc,
0xdd, 0xdd, 0xdd, 0xdd,
},
- execInstrCopyin, dataOffset + 18, execArgConst, 2, 0x43,
- callID("test$array2"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 18, execArgConst, 2, 0x43,
+ callID("test$array2"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -239,11 +239,11 @@ func TestSerializeForExec(t *testing.T) {
{
"test$end0(&(0x7f0000000000)={0x42, 0x42, 0x42, 0x42})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 1, 0x42,
- execInstrCopyin, dataOffset + 1, execArgConst, 2 | 1<<8, 0x42,
- execInstrCopyin, dataOffset + 3, execArgConst, 4 | 1<<8, 0x42,
- execInstrCopyin, dataOffset + 7, execArgConst, 8 | 1<<8, 0x42,
- callID("test$end0"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 1, 0x42,
+ execInstrCopyin, 1, execArgConst, 2 | 1<<8, 0x42,
+ execInstrCopyin, 3, execArgConst, 4 | 1<<8, 0x42,
+ execInstrCopyin, 7, execArgConst, 8 | 1<<8, 0x42,
+ callID("test$end0"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -251,10 +251,10 @@ func TestSerializeForExec(t *testing.T) {
{
"test$end1(&(0x7f0000000000)={0xe, 0x42, 0x1})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 2 | 1<<8, 0xe,
- execInstrCopyin, dataOffset + 2, execArgConst, 4 | 1<<8, 0x42,
- execInstrCopyin, dataOffset + 6, execArgConst, 8 | 1<<8, 0x1,
- callID("test$end1"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 2 | 1<<8, 0xe,
+ execInstrCopyin, 2, execArgConst, 4 | 1<<8, 0x42,
+ execInstrCopyin, 6, execArgConst, 8 | 1<<8, 0x1,
+ callID("test$end1"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -262,15 +262,15 @@ func TestSerializeForExec(t *testing.T) {
{
"test$bf0(&(0x7f0000000000)={0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 2 | 0<<16 | 10<<24, 0x42,
- execInstrCopyin, dataOffset + 8, execArgConst, 8, 0x42,
- execInstrCopyin, dataOffset + 16, execArgConst, 2 | 0<<16 | 5<<24, 0x42,
- execInstrCopyin, dataOffset + 16, execArgConst, 2 | 5<<16 | 6<<24, 0x42,
- execInstrCopyin, dataOffset + 16, execArgConst, 4 | 11<<16 | 15<<24, 0x42,
- execInstrCopyin, dataOffset + 20, execArgConst, 2 | 0<<16 | 11<<24, 0x42,
- execInstrCopyin, dataOffset + 22, execArgConst, 2 | 1<<8 | 0<<16 | 11<<24, 0x42,
- execInstrCopyin, dataOffset + 24, execArgConst, 1, 0x42,
- callID("test$bf0"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 2 | 0<<16 | 10<<24, 0x42,
+ execInstrCopyin, 8, execArgConst, 8, 0x42,
+ execInstrCopyin, 16, execArgConst, 2 | 0<<16 | 5<<24, 0x42,
+ execInstrCopyin, 16, execArgConst, 2 | 5<<16 | 6<<24, 0x42,
+ execInstrCopyin, 16, execArgConst, 4 | 11<<16 | 15<<24, 0x42,
+ execInstrCopyin, 20, execArgConst, 2 | 0<<16 | 11<<24, 0x42,
+ execInstrCopyin, 22, execArgConst, 2 | 1<<8 | 0<<16 | 11<<24, 0x42,
+ execInstrCopyin, 24, execArgConst, 1, 0x42,
+ callID("test$bf0"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
&ExecProg{
@@ -362,11 +362,11 @@ func TestSerializeForExec(t *testing.T) {
{
"test$bf1(&(0x7f0000000000)={{0x42, 0x42, 0x42}, 0x42})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 4 | 0<<16 | 10<<24, 0x42,
- execInstrCopyin, dataOffset + 0, execArgConst, 4 | 10<<16 | 10<<24, 0x42,
- execInstrCopyin, dataOffset + 0, execArgConst, 4 | 20<<16 | 10<<24, 0x42,
- execInstrCopyin, dataOffset + 4, execArgConst, 1, 0x42,
- callID("test$bf1"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 4 | 0<<16 | 10<<24, 0x42,
+ execInstrCopyin, 0, execArgConst, 4 | 10<<16 | 10<<24, 0x42,
+ execInstrCopyin, 0, execArgConst, 4 | 20<<16 | 10<<24, 0x42,
+ execInstrCopyin, 4, execArgConst, 1, 0x42,
+ callID("test$bf1"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -400,7 +400,7 @@ func TestSerializeForExec(t *testing.T) {
// NULL pointer must be encoded os 0.
"test$opt1(0x0)",
[]any{
- callID("test$opt1"), ExecNoCopyout, 1, execArgConst, 8, 0,
+ callID("test$opt1"), ExecNoCopyout, 1, execArgAddr64, -dataOffset,
execInstrEOF,
},
nil,
@@ -408,14 +408,14 @@ func TestSerializeForExec(t *testing.T) {
{
"test$align7(&(0x7f0000000000)={{0x1, 0x2, 0x3, 0x4, 0x5, 0x6}, 0x42})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 1 | 0<<16 | 1<<24, 0x1,
- execInstrCopyin, dataOffset + 0, execArgConst, 1 | 1<<16 | 1<<24, 0x2,
- execInstrCopyin, dataOffset + 0, execArgConst, 1 | 2<<16 | 1<<24, 0x3,
- execInstrCopyin, dataOffset + 0, execArgConst, 2 | 3<<16 | 1<<24, 0x4,
- execInstrCopyin, dataOffset + 0, execArgConst, 2 | 4<<16 | 1<<24, 0x5,
- execInstrCopyin, dataOffset + 0, execArgConst, 2 | 5<<16 | 1<<24, 0x6,
- execInstrCopyin, dataOffset + 8, execArgConst, 1, 0x42,
- callID("test$align7"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ execInstrCopyin, 0, execArgConst, 1 | 0<<16 | 1<<24, 0x1,
+ execInstrCopyin, 0, execArgConst, 1 | 1<<16 | 1<<24, 0x2,
+ execInstrCopyin, 0, execArgConst, 1 | 2<<16 | 1<<24, 0x3,
+ execInstrCopyin, 0, execArgConst, 2 | 3<<16 | 1<<24, 0x4,
+ execInstrCopyin, 0, execArgConst, 2 | 4<<16 | 1<<24, 0x5,
+ execInstrCopyin, 0, execArgConst, 2 | 5<<16 | 1<<24, 0x6,
+ execInstrCopyin, 8, execArgConst, 1, 0x42,
+ callID("test$align7"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
nil,
@@ -423,7 +423,7 @@ func TestSerializeForExec(t *testing.T) {
{
"test$excessive_fields1(0x0)",
[]any{
- callID("test$excessive_fields1"), ExecNoCopyout, 1, execArgConst, ptrSize, 0x0,
+ callID("test$excessive_fields1"), ExecNoCopyout, 1, execArgAddr64, -dataOffset,
execInstrEOF,
},
nil,
@@ -431,7 +431,7 @@ func TestSerializeForExec(t *testing.T) {
{
"test$excessive_fields1(0xffffffffffffffff)",
[]any{
- callID("test$excessive_fields1"), ExecNoCopyout, 1, execArgConst, ptrSize, uint64(0xffffffffffffffff),
+ callID("test$excessive_fields1"), ExecNoCopyout, 1, execArgAddr64, 0xffffffffffffffff - dataOffset,
execInstrEOF,
},
nil,
@@ -439,7 +439,7 @@ func TestSerializeForExec(t *testing.T) {
{
"test$excessive_fields1(0xfffffffffffffffe)",
[]any{
- callID("test$excessive_fields1"), ExecNoCopyout, 1, execArgConst, ptrSize, uint64(0x9999999999999999),
+ callID("test$excessive_fields1"), ExecNoCopyout, 1, execArgAddr64, 0x9999999999999999 - dataOffset,
execInstrEOF,
},
nil,
@@ -447,23 +447,122 @@ func TestSerializeForExec(t *testing.T) {
{
"test$csum_ipv4_tcp(&(0x7f0000000000)={{0x0, 0x1, 0x2}, {{0x0}, \"ab\"}})",
[]any{
- execInstrCopyin, dataOffset + 0, execArgConst, 2, 0x0,
- execInstrCopyin, dataOffset + 2, execArgConst, 4 | 1<<8, 0x1,
- execInstrCopyin, dataOffset + 6, execArgConst, 4 | 1<<8, 0x2,
- execInstrCopyin, dataOffset + 10, execArgConst, 2, 0x0,
- execInstrCopyin, dataOffset + 12, execArgData, 1, []byte{0xab},
- execInstrCopyin, dataOffset + 10, execArgCsum, 2, ExecArgCsumInet, 5,
- ExecArgCsumChunkData, dataOffset + 2, 4,
- ExecArgCsumChunkData, dataOffset + 6, 4,
+ execInstrCopyin, 0, execArgConst, 2, 0x0,
+ execInstrCopyin, 2, execArgConst, 4 | 1<<8, 0x1,
+ execInstrCopyin, 6, execArgConst, 4 | 1<<8, 0x2,
+ execInstrCopyin, 10, execArgConst, 2, 0x0,
+ execInstrCopyin, 12, execArgData, 1, []byte{0xab},
+ execInstrCopyin, 10, execArgCsum, 2, ExecArgCsumInet, 5,
+ ExecArgCsumChunkData, 2, 4,
+ ExecArgCsumChunkData, 6, 4,
ExecArgCsumChunkConst, 0x0600, 2,
ExecArgCsumChunkConst, 0x0300, 2,
- ExecArgCsumChunkData, dataOffset + 10, 3,
- execInstrCopyin, dataOffset + 0, execArgCsum, 2, ExecArgCsumInet, 1,
- ExecArgCsumChunkData, dataOffset + 0, 10,
- callID("test$csum_ipv4_tcp"), ExecNoCopyout, 1, execArgConst, ptrSize, dataOffset,
+ ExecArgCsumChunkData, 10, 3,
+ execInstrCopyin, 0, execArgCsum, 2, ExecArgCsumInet, 1,
+ ExecArgCsumChunkData, 0, 10,
+ callID("test$csum_ipv4_tcp"), ExecNoCopyout, 1, execArgAddr64, 0,
execInstrEOF,
},
- nil,
+ &ExecProg{
+ Calls: []ExecCall{
+ {
+ Meta: target.SyscallMap["test$csum_ipv4_tcp"],
+ Index: ExecNoCopyout,
+ Args: []ExecArg{
+ ExecArgConst{
+ Value: dataOffset,
+ Size: 8,
+ },
+ },
+ Copyin: []ExecCopyin{
+ {
+ Addr: dataOffset,
+ Arg: ExecArgConst{
+ Value: 0,
+ Size: 2,
+ },
+ },
+ {
+ Addr: dataOffset + 2,
+ Arg: ExecArgConst{
+ Value: 1,
+ Size: 4,
+ Format: FormatBigEndian,
+ },
+ },
+ {
+ Addr: dataOffset + 6,
+ Arg: ExecArgConst{
+ Value: 2,
+ Size: 4,
+ Format: FormatBigEndian,
+ },
+ },
+ {
+ Addr: dataOffset + 10,
+ Arg: ExecArgConst{
+ Value: 0,
+ Size: 2,
+ },
+ },
+ {
+ Addr: dataOffset + 12,
+ Arg: ExecArgData{
+ Data: []byte{0xab},
+ },
+ },
+ {
+ Addr: dataOffset + 10,
+ Arg: ExecArgCsum{
+ Size: 2,
+ Kind: ExecArgCsumInet,
+ Chunks: []ExecCsumChunk{
+ {
+ Kind: ExecArgCsumChunkData,
+ Value: dataOffset + 2,
+ Size: 4,
+ },
+ {
+ Kind: ExecArgCsumChunkData,
+ Value: dataOffset + 6,
+ Size: 4,
+ },
+ {
+ Kind: ExecArgCsumChunkConst,
+ Value: 0x0600,
+ Size: 2,
+ },
+ {
+ Kind: ExecArgCsumChunkConst,
+ Value: 0x0300,
+ Size: 2,
+ },
+ {
+ Kind: ExecArgCsumChunkData,
+ Value: dataOffset + 10,
+ Size: 3,
+ },
+ },
+ },
+ },
+ {
+ Addr: dataOffset,
+ Arg: ExecArgCsum{
+ Size: 2,
+ Kind: ExecArgCsumInet,
+ Chunks: []ExecCsumChunk{
+ {
+ Kind: ExecArgCsumChunkData,
+ Value: dataOffset,
+ Size: 10,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
},
{
`test() (fail_nth: 3)
@@ -499,6 +598,50 @@ test() (async, rerun: 10)
},
},
},
+ {
+ `test$res3(&(0x7f0000000010)=<r0=>0x0)
+test$res1(r0)
+`,
+ []any{
+ callID("test$res3"), ExecNoCopyout, 1, execArgAddr64, 0x10,
+ execInstrCopyout, 0, 0x10, 4,
+ callID("test$res1"), ExecNoCopyout, 1, execArgResult, 4, 0, 0, 0, 0xffff,
+ execInstrEOF,
+ },
+ &ExecProg{
+ Calls: []ExecCall{
+ {
+ Meta: target.SyscallMap["test$res3"],
+ Index: ExecNoCopyout,
+ Args: []ExecArg{
+ ExecArgConst{
+ Value: dataOffset + 0x10,
+ Size: 8,
+ },
+ },
+ Copyout: []ExecCopyout{
+ {
+ Index: 0,
+ Addr: dataOffset + 0x10,
+ Size: 4,
+ },
+ },
+ },
+ {
+ Meta: target.SyscallMap["test$res1"],
+ Index: ExecNoCopyout,
+ Args: []ExecArg{
+ ExecArgResult{
+ Size: 4,
+ Index: 0,
+ Default: 0xffff,
+ },
+ },
+ },
+ },
+ Vars: []uint64{0xffff},
+ },
+ },
}
buf := make([]byte, ExecBufferSize)