aboutsummaryrefslogtreecommitdiffstats
path: root/prog
diff options
context:
space:
mode:
Diffstat (limited to 'prog')
-rw-r--r--prog/any.go2
-rw-r--r--prog/target.go17
-rw-r--r--prog/test/fuzz.go2
3 files changed, 10 insertions, 11 deletions
diff --git a/prog/any.go b/prog/any.go
index c43d8dd8d..cb49f3494 100644
--- a/prog/any.go
+++ b/prog/any.go
@@ -24,7 +24,7 @@ type anyTypes struct {
func (target *Target) initAnyTypes() {
var anyPtrs *UnionType
- for _, typ := range target.types {
+ for _, typ := range target.Types {
if typ.Name() == "ANYPTRS" {
anyPtrs = typ.(*UnionType)
break
diff --git a/prog/target.go b/prog/target.go
index 50fcecdbc..11127046b 100644
--- a/prog/target.go
+++ b/prog/target.go
@@ -30,6 +30,7 @@ type Target struct {
Resources []*ResourceDesc
Consts []ConstValue
Flags []FlagDesc
+ Types []Type
// MakeDataMmap creates calls that mmaps target data memory range.
MakeDataMmap func() []*Call
@@ -70,8 +71,8 @@ type Target struct {
FlagsMap map[string][]string
init sync.Once
+ fillArch func(target *Target)
initArch func(target *Target)
- types []Type
resourceMap map[string]*ResourceDesc
// Maps resource name to a list of calls that can create the resource.
resourceCtors map[string][]ResourceCtor
@@ -86,20 +87,17 @@ const maxSpecialPointers = 16
var targets = make(map[string]*Target)
-func RegisterTarget(target *Target, types []Type, initArch func(target *Target)) {
+func RegisterTarget(target *Target, fill, init func(target *Target)) {
key := target.OS + "/" + target.Arch
if targets[key] != nil {
panic(fmt.Sprintf("duplicate target %v", key))
}
- target.initArch = initArch
- target.types = types
+ target.fillArch = fill
+ target.initArch = init
targets[key] = target
}
func GetTarget(OS, arch string) (*Target, error) {
- if OS == "android" {
- OS = "linux"
- }
key := OS + "/" + arch
target := targets[key]
if target == nil {
@@ -132,6 +130,7 @@ func AllTargets() []*Target {
func (target *Target) lazyInit() {
target.Neutralize = func(c *Call, fixStructure bool) error { return nil }
target.AnnotateCall = func(c ExecCall) string { return "" }
+ target.fillArch(target)
target.initTarget()
target.initUselessHints()
target.initRelatedFields()
@@ -155,7 +154,7 @@ func (target *Target) lazyInit() {
}
}
// These are used only during lazyInit.
- target.types = nil
+ target.Types = nil
}
func (target *Target) initTarget() {
@@ -165,7 +164,7 @@ func (target *Target) initTarget() {
target.ConstMap[c.Name] = c.Value
}
- target.resourceMap = restoreLinks(target.Syscalls, target.Resources, target.types)
+ target.resourceMap = restoreLinks(target.Syscalls, target.Resources, target.Types)
target.initAnyTypes()
target.SyscallMap = make(map[string]*Syscall)
diff --git a/prog/test/fuzz.go b/prog/test/fuzz.go
index 9b47234b3..98582a818 100644
--- a/prog/test/fuzz.go
+++ b/prog/test/fuzz.go
@@ -9,8 +9,8 @@ import (
"math/rand"
"github.com/google/syzkaller/prog"
+ _ "github.com/google/syzkaller/sys"
"github.com/google/syzkaller/sys/targets"
- _ "github.com/google/syzkaller/sys/test/gen" // import the target we use for fuzzing
)
func FuzzDeserialize(data []byte) int {