aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-02-23 13:43:43 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-02-23 13:50:02 +0100
commit7a7c747c6f5f732d614cea2404386913e68981a0 (patch)
treec62ec3f909aab845d7d5713e916034aeafae157e
parente229ac7779c82d5cdf27243e7699a2175c785f80 (diff)
pkg/compiler: allow unions as syscall arguments
If all union options can be syscall arguments, allow the union itself as syscall argument.
-rw-r--r--executor/syscalls_test.h10
-rw-r--r--pkg/ast/test_util.go6
-rw-r--r--pkg/compiler/check.go32
-rw-r--r--pkg/compiler/testdata/all.txt17
-rw-r--r--pkg/compiler/testdata/consts.txt2
-rw-r--r--pkg/compiler/testdata/errors.txt34
-rw-r--r--pkg/compiler/types.go73
-rw-r--r--prog/encodingexec.go2
-rw-r--r--sys/test/32.go30
-rw-r--r--sys/test/64.go30
-rw-r--r--sys/test/test.txt11
11 files changed, 168 insertions, 79 deletions
diff --git a/executor/syscalls_test.h b/executor/syscalls_test.h
index a63b99c2e..8eac341cf 100644
--- a/executor/syscalls_test.h
+++ b/executor/syscalls_test.h
@@ -2,11 +2,11 @@
#if 0
#define GOARCH "32"
-#define SYZ_REVISION "72645e4224f3941125abe0fb9a917a6c7536cf1a"
+#define SYZ_REVISION "2258fd7490fd41c1b0e0aa537454d223eef7929d"
#define SYZ_PAGE_SIZE 8192
#define SYZ_NUM_PAGES 2048
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 86;
+unsigned syscall_count = 87;
call_t syscalls[] = {
{"mmap", 0, (syscall_t)mmap},
{"mutate0", 0, (syscall_t)mutate0},
@@ -86,6 +86,7 @@ call_t syscalls[] = {
{"syz_test$res1", 0, (syscall_t)syz_test},
{"syz_test$struct", 0, (syscall_t)syz_test},
{"syz_test$syz_union3", 0, (syscall_t)syz_test},
+ {"syz_test$syz_union4", 0, (syscall_t)syz_test},
{"syz_test$text_x86_16", 0, (syscall_t)syz_test},
{"syz_test$text_x86_32", 0, (syscall_t)syz_test},
{"syz_test$text_x86_64", 0, (syscall_t)syz_test},
@@ -100,11 +101,11 @@ call_t syscalls[] = {
#if 0
#define GOARCH "64"
-#define SYZ_REVISION "15f0bc6f3e0ba695754a37d2497a9929f1457f47"
+#define SYZ_REVISION "90f61a2054a8cefadc6cf2027a18e4073a9054ae"
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 86;
+unsigned syscall_count = 87;
call_t syscalls[] = {
{"mmap", 0, (syscall_t)mmap},
{"mutate0", 0, (syscall_t)mutate0},
@@ -184,6 +185,7 @@ call_t syscalls[] = {
{"syz_test$res1", 0, (syscall_t)syz_test},
{"syz_test$struct", 0, (syscall_t)syz_test},
{"syz_test$syz_union3", 0, (syscall_t)syz_test},
+ {"syz_test$syz_union4", 0, (syscall_t)syz_test},
{"syz_test$text_x86_16", 0, (syscall_t)syz_test},
{"syz_test$text_x86_32", 0, (syscall_t)syz_test},
{"syz_test$text_x86_64", 0, (syscall_t)syz_test},
diff --git a/pkg/ast/test_util.go b/pkg/ast/test_util.go
index b9fe12152..fbec645b7 100644
--- a/pkg/ast/test_util.go
+++ b/pkg/ast/test_util.go
@@ -8,6 +8,7 @@ import (
"bytes"
"io/ioutil"
"path/filepath"
+ "regexp"
"strings"
"testing"
)
@@ -60,7 +61,12 @@ func NewErrorMatcher(t *testing.T, file string) *ErrorMatcher {
}
}
+var errorLocationRe = regexp.MustCompile("at [a-z][a-z0-9]+\\.txt:[0-9]+:[0-9]+")
+
func (em *ErrorMatcher) ErrorHandler(pos Pos, msg string) {
+ if match := errorLocationRe.FindStringSubmatchIndex(msg); match != nil {
+ msg = msg[0:match[0]] + "at LOCATION" + msg[match[1]:]
+ }
em.got = append(em.got, &errorDesc{
file: pos.File,
line: pos.Line,
diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go
index e7333b9ae..2c11d7bff 100644
--- a/pkg/compiler/check.go
+++ b/pkg/compiler/check.go
@@ -209,7 +209,7 @@ func (comp *compiler) checkTypes() {
comp.checkType(checkCtx{}, a.Type, checkIsArg)
}
if n.Ret != nil {
- comp.checkType(checkCtx{}, n.Ret, checkIsArg|checkIsRet|checkIsRetCtx)
+ comp.checkType(checkCtx{}, n.Ret, checkIsArg|checkIsRet)
}
}
}
@@ -544,7 +544,6 @@ type checkFlags int
const (
checkIsArg checkFlags = 1 << iota // immidiate syscall arg type
checkIsRet // immidiate syscall ret type
- checkIsRetCtx // inside of syscall ret type
checkIsStruct // immidiate struct field type
checkIsResourceBase // immidiate resource base type
checkIsTypedef // immidiate type alias/template type
@@ -584,18 +583,6 @@ func (comp *compiler) checkType(ctx checkCtx, t *ast.Type, flags checkFlags) {
return
}
}
- if flags&checkIsRet != 0 && (!desc.CanBeArg || desc.CantBeRet) {
- comp.error(t.Pos, "%v can't be syscall return", t.Ident)
- return
- }
- if flags&checkIsRetCtx != 0 && desc.CantBeRet {
- comp.error(t.Pos, "%v can't be used in syscall return", t.Ident)
- return
- }
- if flags&checkIsArg != 0 && !desc.CanBeArg {
- comp.error(t.Pos, "%v can't be syscall argument", t.Ident)
- return
- }
if flags&checkIsTypedef != 0 && !desc.CanBeTypedef {
comp.error(t.Pos, "%v can't be type alias target", t.Ident)
return
@@ -636,11 +623,23 @@ func (comp *compiler) checkType(ctx checkCtx, t *ast.Type, flags checkFlags) {
err0 := comp.errors
for i, arg := range args {
if desc.Args[i].Type == typeArgType {
- comp.checkType(ctx, arg, flags&checkIsRetCtx)
+ comp.checkType(ctx, arg, 0)
} else {
comp.checkTypeArg(t, arg, desc.Args[i])
}
}
+ canBeArg, canBeRet := false, false
+ if desc.CanBeArgRet != nil {
+ canBeArg, canBeRet = desc.CanBeArgRet(comp, t)
+ }
+ if flags&checkIsRet != 0 && !canBeRet {
+ comp.error(t.Pos, "%v can't be syscall return", t.Ident)
+ return
+ }
+ if flags&checkIsArg != 0 && !canBeArg {
+ comp.error(t.Pos, "%v can't be syscall argument", t.Ident)
+ return
+ }
if desc.Check != nil && err0 == comp.errors {
_, args, base := comp.getArgsBase(t, "", prog.DirIn, flags&checkIsArg != 0)
desc.Check(comp, t, args, base)
@@ -681,6 +680,7 @@ func (comp *compiler) replaceTypedef(ctx *checkCtx, t *ast.Type, desc *typeDesc,
}
return
}
+ pos0 := t.Pos
if typedef.Type != nil {
*t = *typedef.Type.Clone().(*ast.Type)
if !comp.instantiate(t, typedef.Args, args) {
@@ -698,10 +698,10 @@ func (comp *compiler) replaceTypedef(ctx *checkCtx, t *ast.Type, desc *typeDesc,
comp.structs[fullTypeName] = inst
}
*t = ast.Type{
- Pos: t.Pos,
Ident: fullTypeName,
}
}
+ t.Pos = pos0
// Remove base type if it's not needed in this context.
desc = comp.getTypeDesc(t)
diff --git a/pkg/compiler/testdata/all.txt b/pkg/compiler/testdata/all.txt
index dd2a90ba3..442f08774 100644
--- a/pkg/compiler/testdata/all.txt
+++ b/pkg/compiler/testdata/all.txt
@@ -3,7 +3,21 @@
foo$0(a int8)
foo$1(a int8[C1:C2])
-foo$2() ptr[out, array[int32]]
+foo$2(a ptr[out, array[int32]])
+foo$3(a union_arg)
+foo$4() r0
+
+resource r0[intptr]
+
+union_arg [
+ f1 int8
+ f2 int64
+ f3 ptr[in, int32]
+ f4 r0
+ f5 const[1, intptr]
+ f6 flags[int_flags, int32]
+ f7 proc[0, 1, int16]
+]
strings {
f1 string
@@ -22,6 +36,7 @@ strings {
string_flags1 = "foo", "barbaz"
string_flags2 = ""
+int_flags = 0, 1
# Proc type.
diff --git a/pkg/compiler/testdata/consts.txt b/pkg/compiler/testdata/consts.txt
index 468f86681..b0bf8d4f1 100644
--- a/pkg/compiler/testdata/consts.txt
+++ b/pkg/compiler/testdata/consts.txt
@@ -11,7 +11,7 @@ flags = CONST3, CONST2, CONST1
define CONST1 1
define CONST2 FOOBAR + 1
-foo(x const[CONST4]) ptr[out, array[int32, CONST5]]
+foo(x const[CONST4], y ptr[out, array[int32, CONST5]])
bar$BAR()
str {
diff --git a/pkg/compiler/testdata/errors.txt b/pkg/compiler/testdata/errors.txt
index f4c9cf69a..8ea03bc7b 100644
--- a/pkg/compiler/testdata/errors.txt
+++ b/pkg/compiler/testdata/errors.txt
@@ -8,7 +8,7 @@ foo$3(x string) ### string can't be syscall argument
resource r0[int32]: 0, 0x1
resource r1[string["foo"]] ### string can't be resource base (int types can)
-resource r1[int32] ### type r1 redeclared, previously declared as resource at errors.txt:10:1
+resource r1[int32] ### type r1 redeclared, previously declared as resource at LOCATION
resource int32[int32] ### resource name int32 conflicts with builtin type
resource fileoff[intptr] ### resource name fileoff conflicts with builtin type
@@ -16,7 +16,7 @@ s1 {
f1 int32
}
-s1 { ### type s1 redeclared, previously declared as struct at errors.txt:15:1
+s1 { ### type s1 redeclared, previously declared as struct at LOCATION
f1 int32
f1 intptr ### duplicate field f1 in struct s1
parent int8 ### reserved field name parent in struct s1
@@ -29,7 +29,7 @@ int32 { ### struct name int32 conflicts with builtin type
f1 int32
}
-r0 { ### type r0 redeclared, previously declared as resource at errors.txt:9:1
+r0 { ### type r0 redeclared, previously declared as resource at LOCATION
f1 int32
}
@@ -48,18 +48,18 @@ u2 [
]
foo$4(a int8, a int16) ### duplicate argument a in syscall foo$4
-foo$4() ### syscall foo$4 redeclared, previously declared at errors.txt:50:1
+foo$4() ### syscall foo$4 redeclared, previously declared at LOCATION
foo()
-foo() ### syscall foo redeclared, previously declared at errors.txt:52:1
+foo() ### syscall foo redeclared, previously declared at LOCATION
foo$5(a0 int8, a1 int8, a2 int8, a3 int8, a4 int8, a5 int8, a6 int8, a7 int8, a8 int8, a9 int8) ### syscall foo$5 has 10 arguments, allowed maximum is 9
foo$6(parent int8) ### reserved argument name parent in syscall foo$6
f1 = 1
f2 = 1, 2
-f2 = 1, 2 ### flags f2 redeclared, previously declared at errors.txt:58:1
+f2 = 1, 2 ### flags f2 redeclared, previously declared at LOCATION
sf1 = "a"
sf2 = "a", "b"
-sf2 = "c" ### string flags sf2 redeclared, previously declared at errors.txt:61:1
+sf2 = "c" ### string flags sf2 redeclared, previously declared at LOCATION
resource r2[r0]: 2
resource r3[int32:1] ### unexpected ':', only struct fields can be bitfields
@@ -112,6 +112,10 @@ foo$55(a int8[opt[int8]]) ### opt can't have arguments
foo$56(a void) ### void can't be syscall argument
foo$57(a ptr[in, stringnoz["foo", 10]]) ### fixed-size string can't be non-zero-terminated
foo$58(a ptr[in, stringnoz[sf2, 10]]) ### fixed-size string can't be non-zero-terminated
+foo$59(a s1) ### s1 can't be syscall argument
+foo$60() s1 ### s1 can't be syscall return
+foo$61(a u6) ### u6 can't be syscall argument
+foo$62() u6 ### u6 can't be syscall return
opt { ### struct uses reserved name opt
f1 int32
@@ -171,6 +175,12 @@ u5 [
f2 int8:2 ### unexpected ':', only struct fields can be bitfields
]
+u6 [
+ f1 int8
+ f2 int64
+ f3 array[int8]
+]
+
define d0 SOMETHING
define d1 `some C expression`
define d2 some C expression
@@ -189,8 +199,8 @@ typestruct {
}
type type0 int8
-type type0 int8 ### type type0 redeclared, previously declared as type alias at errors.txt:191:6
-resource type0[int32] ### type type0 redeclared, previously declared as type alias at errors.txt:191:6
+type type0 int8 ### type type0 redeclared, previously declared as type alias at LOCATION
+resource type0[int32] ### type type0 redeclared, previously declared as type alias at LOCATION
type0 = 0, 1
type type1 type1 ### type instantiation loop: type1 -> type1
type type2 int8:4 ### unexpected ':', only struct fields can be bitfields
@@ -226,7 +236,7 @@ foo$100(a mybool8, b mybool16)
foo$102(a type2) ### unknown type type2
foo$103(a type0:4) ### type alias type0 with ':'
foo$104(a type0[opt]) ### type type0 is not a template
-foo$105() type0
+foo$105() type0 ### int8 can't be syscall return
foo$106() type6 ### unknown type type6
foo$107(a type9, b type12)
foo$108(a flags[type0])
@@ -243,8 +253,8 @@ type templ6[T] ptr[in, T]
type templ7 templ0[templ6, int8]
# Note: here 42 is stripped as base type, so const ends up without arguments.
-foo$201(a templ1[42])
-type templ1[A] const[A] ### wrong number of arguments for type const, expect value
+foo$201(a templ1[42]) ### wrong number of arguments for type const, expect value
+type templ1[A] const[A]
type templ_struct0[A, B] {
len len[parent, int16]
diff --git a/pkg/compiler/types.go b/pkg/compiler/types.go
index 847849f2e..4c1123521 100644
--- a/pkg/compiler/types.go
+++ b/pkg/compiler/types.go
@@ -14,15 +14,15 @@ import (
// typeDesc is arg/field type descriptor.
type typeDesc struct {
Names []string
- CanBeArg bool // can be argument of syscall?
CanBeTypedef bool // can be type alias target?
CantBeOpt bool // can't be marked as opt?
- CantBeRet bool // can't be syscall return (directly or indirectly)?
NeedBase bool // needs base type when used as field?
AllowColon bool // allow colon (int8:2) on fields?
ResourceBase bool // can be resource base type?
OptArgs int // number of optional arguments in Args array
Args []namedArg // type arguments
+ // CanBeArgRet returns if this type can be syscall argument/return (false if nil).
+ CanBeArgRet func(comp *compiler, t *ast.Type) (bool, bool)
// Check does custom verification of the type (optional, consts are not patched yet).
Check func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon)
// CheckConsts does custom verification of the type (optional, consts are patched).
@@ -57,9 +57,12 @@ const (
kindString
)
+func canBeArg(comp *compiler, t *ast.Type) (bool, bool) { return true, false }
+func canBeArgRet(comp *compiler, t *ast.Type) (bool, bool) { return true, true }
+
var typeInt = &typeDesc{
Names: typeArgBase.Type.Names,
- CanBeArg: true,
+ CanBeArgRet: canBeArg,
CanBeTypedef: true,
AllowColon: true,
ResourceBase: true,
@@ -86,7 +89,7 @@ var typeInt = &typeDesc{
var typePtr = &typeDesc{
Names: []string{"ptr", "ptr64"},
- CanBeArg: true,
+ CanBeArgRet: canBeArg,
CanBeTypedef: true,
Args: []namedArg{{"direction", typeArgDir}, {"type", typeArgType}},
Gen: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) prog.Type {
@@ -105,7 +108,6 @@ var typePtr = &typeDesc{
var typeVoid = &typeDesc{
Names: []string{"void"},
CantBeOpt: true,
- CantBeRet: true,
ZeroSize: func(comp *compiler, t *ast.Type, args []*ast.Type) bool {
return true
},
@@ -181,12 +183,11 @@ var typeArray = &typeDesc{
}
var typeLen = &typeDesc{
- Names: []string{"len", "bytesize", "bytesize2", "bytesize4", "bytesize8", "bitsize"},
- CanBeArg: true,
- CantBeOpt: true,
- CantBeRet: true,
- NeedBase: true,
- Args: []namedArg{{"len target", typeArgLenTarget}},
+ Names: []string{"len", "bytesize", "bytesize2", "bytesize4", "bytesize8", "bitsize"},
+ CanBeArgRet: canBeArg,
+ CantBeOpt: true,
+ NeedBase: true,
+ Args: []namedArg{{"len target", typeArgLenTarget}},
Gen: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) prog.Type {
var bitSize uint64
switch t.Ident {
@@ -208,7 +209,7 @@ var typeLen = &typeDesc{
var typeConst = &typeDesc{
Names: []string{"const"},
- CanBeArg: true,
+ CanBeArgRet: canBeArg,
CanBeTypedef: true,
CantBeOpt: true,
NeedBase: true,
@@ -227,7 +228,7 @@ var typeArgLenTarget = &typeArg{
var typeFlags = &typeDesc{
Names: []string{"flags"},
- CanBeArg: true,
+ CanBeArgRet: canBeArg,
CanBeTypedef: true,
CantBeOpt: true,
NeedBase: true,
@@ -276,10 +277,10 @@ var typeFilename = &typeDesc{
}
var typeFileoff = &typeDesc{
- Names: []string{"fileoff"},
- CanBeArg: true,
- CantBeOpt: true,
- NeedBase: true,
+ Names: []string{"fileoff"},
+ CanBeArgRet: canBeArg,
+ CantBeOpt: true,
+ NeedBase: true,
Gen: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) prog.Type {
return &prog.IntType{
IntTypeCommon: base,
@@ -289,10 +290,10 @@ var typeFileoff = &typeDesc{
}
var typeVMA = &typeDesc{
- Names: []string{"vma"},
- CanBeArg: true,
- OptArgs: 1,
- Args: []namedArg{{"size range", typeArgRange}},
+ Names: []string{"vma"},
+ CanBeArgRet: canBeArg,
+ OptArgs: 1,
+ Args: []namedArg{{"size range", typeArgRange}},
Gen: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) prog.Type {
begin, end := uint64(0), uint64(0)
if len(args) > 0 {
@@ -311,7 +312,6 @@ var typeCsum = &typeDesc{
Names: []string{"csum"},
NeedBase: true,
CantBeOpt: true,
- CantBeRet: true,
OptArgs: 1,
Args: []namedArg{{"csum target", typeArgLenTarget}, {"kind", typeArgCsumType}, {"proto", typeArgInt}},
Check: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) {
@@ -351,7 +351,7 @@ func genCsumKind(t *ast.Type) prog.CsumKind {
var typeProc = &typeDesc{
Names: []string{"proc"},
- CanBeArg: true,
+ CanBeArgRet: canBeArg,
CanBeTypedef: true,
NeedBase: true,
Args: []namedArg{{"range start", typeArgInt}, {"per-proc values", typeArgInt}},
@@ -422,9 +422,9 @@ func genTextType(t *ast.Type) prog.TextKind {
}
var typeBuffer = &typeDesc{
- Names: []string{"buffer"},
- CanBeArg: true,
- Args: []namedArg{{"direction", typeArgDir}},
+ Names: []string{"buffer"},
+ CanBeArgRet: canBeArg,
+ Args: []namedArg{{"direction", typeArgDir}},
Gen: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) prog.Type {
base.TypeSize = comp.ptrSize
common := genCommon("", "", 0, genDir(args[0]), false)
@@ -563,7 +563,7 @@ var typeArgType = &typeArg{}
var typeResource = &typeDesc{
// No Names, but getTypeDesc knows how to match it.
- CanBeArg: true,
+ CanBeArgRet: canBeArgRet,
ResourceBase: true,
// Gen is assigned below to avoid initialization loop.
}
@@ -591,6 +591,25 @@ var typeStruct = &typeDesc{
}
func init() {
+ typeStruct.CanBeArgRet = func(comp *compiler, t *ast.Type) (bool, bool) {
+ // Allow unions to be arg if all options can be arg.
+ s := comp.structs[t.Ident]
+ if !s.IsUnion {
+ return false, false
+ }
+ canBeArg := true
+ for _, fld := range s.Fields {
+ desc := comp.getTypeDesc(fld.Type)
+ if desc == nil || desc.CanBeArgRet == nil {
+ return false, false
+ }
+ canBeArg1, _ := desc.CanBeArgRet(comp, fld.Type)
+ if !canBeArg1 {
+ canBeArg = false
+ }
+ }
+ return canBeArg, false
+ }
typeStruct.Varlen = func(comp *compiler, t *ast.Type, args []*ast.Type) bool {
if varlen, ok := comp.structVarlen[t.Ident]; ok {
return varlen
diff --git a/prog/encodingexec.go b/prog/encodingexec.go
index 27fa63350..8ecec3a03 100644
--- a/prog/encodingexec.go
+++ b/prog/encodingexec.go
@@ -264,6 +264,8 @@ func (w *execContext) writeArg(arg Arg) {
copy(w.buf, data)
w.buf = w.buf[padded:]
}
+ case *UnionArg:
+ w.writeArg(a.Option)
default:
panic("unknown arg type")
}
diff --git a/sys/test/32.go b/sys/test/32.go
index 8314d7845..e6399861f 100644
--- a/sys/test/32.go
+++ b/sys/test/32.go
@@ -418,6 +418,15 @@ var structDescs_32 = []*KeyedStruct{
{Key: StructKey{Name: "syz_union3"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "syz_union3", TypeSize: 4}, Fields: []Type{
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "f0", TypeSize: 4}}},
}}},
+ {Key: StructKey{Name: "union_arg"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "union_arg", TypeSize: 8}, Fields: []Type{
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f1", TypeSize: 1}}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int64", FldName: "f2", TypeSize: 8}}},
+ &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "f3", TypeSize: 4}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}},
+ &ResourceType{TypeCommon: TypeCommon{TypeName: "fd", FldName: "f4", TypeSize: 4}},
+ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "f5", TypeSize: 4}}, Val: 1},
+ &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "syz_length_flags", FldName: "f6", TypeSize: 4}}, Vals: []uint64{0, 1}},
+ &ProcType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "proc", FldName: "f7", TypeSize: 2}}, ValuesPerProc: 1},
+ }}},
}
var syscalls_32 = []*Syscall{
@@ -668,32 +677,35 @@ var syscalls_32 = []*Syscall{
{ID: 77, Name: "syz_test$syz_union3", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 4}, Type: &UnionType{Key: StructKey{Name: "syz_union3"}}},
}},
- {ID: 78, Name: "syz_test$text_x86_16", CallName: "syz_test", Args: []Type{
+ {ID: 78, Name: "syz_test$syz_union4", CallName: "syz_test", Args: []Type{
+ &UnionType{Key: StructKey{Name: "union_arg"}, FldName: "a0"},
+ }},
+ {ID: 79, Name: "syz_test$text_x86_16", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 4}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "text", IsVarlen: true}, Kind: 4, Text: 1}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "a1", TypeSize: 4}}, Buf: "a0"},
}},
- {ID: 79, Name: "syz_test$text_x86_32", CallName: "syz_test", Args: []Type{
+ {ID: 80, Name: "syz_test$text_x86_32", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 4}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "text", IsVarlen: true}, Kind: 4, Text: 2}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "a1", TypeSize: 4}}, Buf: "a0"},
}},
- {ID: 80, Name: "syz_test$text_x86_64", CallName: "syz_test", Args: []Type{
+ {ID: 81, Name: "syz_test$text_x86_64", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 4}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "text", IsVarlen: true}, Kind: 4, Text: 3}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "a1", TypeSize: 4}}, Buf: "a0"},
}},
- {ID: 81, Name: "syz_test$text_x86_real", CallName: "syz_test", Args: []Type{
+ {ID: 82, Name: "syz_test$text_x86_real", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 4}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "text", IsVarlen: true}, Kind: 4}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "a1", TypeSize: 4}}, Buf: "a0"},
}},
- {ID: 82, Name: "syz_test$union0", CallName: "syz_test", Args: []Type{
+ {ID: 83, Name: "syz_test$union0", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 4}, Type: &StructType{Key: StructKey{Name: "syz_union0_struct"}}},
}},
- {ID: 83, Name: "syz_test$union1", CallName: "syz_test", Args: []Type{
+ {ID: 84, Name: "syz_test$union1", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 4}, Type: &StructType{Key: StructKey{Name: "syz_union1_struct"}}},
}},
- {ID: 84, Name: "syz_test$union2", CallName: "syz_test", Args: []Type{
+ {ID: 85, Name: "syz_test$union2", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 4}, Type: &StructType{Key: StructKey{Name: "syz_union2_struct"}}},
}},
- {ID: 85, Name: "syz_test$vma0", CallName: "syz_test", Args: []Type{
+ {ID: 86, Name: "syz_test$vma0", CallName: "syz_test", Args: []Type{
&VmaType{TypeCommon: TypeCommon{TypeName: "vma", FldName: "v0", TypeSize: 4}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "l0", TypeSize: 4}}, Buf: "v0"},
&VmaType{TypeCommon: TypeCommon{TypeName: "vma", FldName: "v1", TypeSize: 4}, RangeBegin: 5, RangeEnd: 5},
@@ -710,4 +722,4 @@ var consts_32 = []ConstValue{
{Name: "ONLY_32BITS_CONST", Value: 1},
}
-const revision_32 = "72645e4224f3941125abe0fb9a917a6c7536cf1a"
+const revision_32 = "2258fd7490fd41c1b0e0aa537454d223eef7929d"
diff --git a/sys/test/64.go b/sys/test/64.go
index 7e16dd6f8..27d56ea9d 100644
--- a/sys/test/64.go
+++ b/sys/test/64.go
@@ -417,6 +417,15 @@ var structDescs_64 = []*KeyedStruct{
{Key: StructKey{Name: "syz_union3"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "syz_union3", TypeSize: 4}, Fields: []Type{
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "f0", TypeSize: 4}}},
}}},
+ {Key: StructKey{Name: "union_arg"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "union_arg", TypeSize: 8}, Fields: []Type{
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f1", TypeSize: 1}}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int64", FldName: "f2", TypeSize: 8}}},
+ &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "f3", TypeSize: 8}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}},
+ &ResourceType{TypeCommon: TypeCommon{TypeName: "fd", FldName: "f4", TypeSize: 4}},
+ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "f5", TypeSize: 8}}, Val: 1},
+ &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "syz_length_flags", FldName: "f6", TypeSize: 4}}, Vals: []uint64{0, 1}},
+ &ProcType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "proc", FldName: "f7", TypeSize: 2}}, ValuesPerProc: 1},
+ }}},
}
var syscalls_64 = []*Syscall{
@@ -667,32 +676,35 @@ var syscalls_64 = []*Syscall{
{ID: 77, Name: "syz_test$syz_union3", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &UnionType{Key: StructKey{Name: "syz_union3"}}},
}},
- {ID: 78, Name: "syz_test$text_x86_16", CallName: "syz_test", Args: []Type{
+ {ID: 78, Name: "syz_test$syz_union4", CallName: "syz_test", Args: []Type{
+ &UnionType{Key: StructKey{Name: "union_arg"}, FldName: "a0"},
+ }},
+ {ID: 79, Name: "syz_test$text_x86_16", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "text", IsVarlen: true}, Kind: 4, Text: 1}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "a1", TypeSize: 8}}, Buf: "a0"},
}},
- {ID: 79, Name: "syz_test$text_x86_32", CallName: "syz_test", Args: []Type{
+ {ID: 80, Name: "syz_test$text_x86_32", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "text", IsVarlen: true}, Kind: 4, Text: 2}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "a1", TypeSize: 8}}, Buf: "a0"},
}},
- {ID: 80, Name: "syz_test$text_x86_64", CallName: "syz_test", Args: []Type{
+ {ID: 81, Name: "syz_test$text_x86_64", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "text", IsVarlen: true}, Kind: 4, Text: 3}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "a1", TypeSize: 8}}, Buf: "a0"},
}},
- {ID: 81, Name: "syz_test$text_x86_real", CallName: "syz_test", Args: []Type{
+ {ID: 82, Name: "syz_test$text_x86_real", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "text", IsVarlen: true}, Kind: 4}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "a1", TypeSize: 8}}, Buf: "a0"},
}},
- {ID: 82, Name: "syz_test$union0", CallName: "syz_test", Args: []Type{
+ {ID: 83, Name: "syz_test$union0", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "syz_union0_struct"}}},
}},
- {ID: 83, Name: "syz_test$union1", CallName: "syz_test", Args: []Type{
+ {ID: 84, Name: "syz_test$union1", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "syz_union1_struct"}}},
}},
- {ID: 84, Name: "syz_test$union2", CallName: "syz_test", Args: []Type{
+ {ID: 85, Name: "syz_test$union2", CallName: "syz_test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "syz_union2_struct"}}},
}},
- {ID: 85, Name: "syz_test$vma0", CallName: "syz_test", Args: []Type{
+ {ID: 86, Name: "syz_test$vma0", CallName: "syz_test", Args: []Type{
&VmaType{TypeCommon: TypeCommon{TypeName: "vma", FldName: "v0", TypeSize: 8}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "l0", TypeSize: 8}}, Buf: "v0"},
&VmaType{TypeCommon: TypeCommon{TypeName: "vma", FldName: "v1", TypeSize: 8}, RangeBegin: 5, RangeEnd: 5},
@@ -708,4 +720,4 @@ var consts_64 = []ConstValue{
{Name: "IPPROTO_UDP", Value: 17},
}
-const revision_64 = "15f0bc6f3e0ba695754a37d2497a9929f1457f47"
+const revision_64 = "90f61a2054a8cefadc6cf2027a18e4073a9054ae"
diff --git a/sys/test/test.txt b/sys/test/test.txt
index 1955b007b..d63ed598b 100644
--- a/sys/test/test.txt
+++ b/sys/test/test.txt
@@ -151,7 +151,18 @@ syz_union3 [
f0 int32
]
+union_arg [
+ f1 int8
+ f2 int64
+ f3 ptr[in, int32]
+ f4 fd
+ f5 const[1, intptr]
+ f6 flags[syz_length_flags, int32]
+ f7 proc[0, 1, int16]
+]
+
syz_test$syz_union3(a0 ptr[in, syz_union3])
+syz_test$syz_union4(a0 union_arg)
# Arrays