diff options
| author | Alexey Kardashevskiy <aik@linux.ibm.com> | 2020-09-02 18:11:22 +1000 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-11-20 15:31:42 +0100 |
| commit | e72f8f11e096d36aefc41a35c718dced97c45dea (patch) | |
| tree | 6619d0089d8ac172c64853c76c0b1acc9485d192 /prog | |
| parent | 740ff4615a9ced4a8a016365aa44674b9b0e807d (diff) | |
pkg/ifuzz: reorganize files to allow other architectures
At the moment ifuzz only generates x86 instructions. In order to support
instruction fuzzing for others (ARM, POWERPC), some separation of
the common and arch layers is needed.
This adds 2 packages:
1. "x86" where x86 instruction generator goes to
2. "ifuzzimpl which contains some common code.
The goal was to keep changes to the rand.go to the minimum.
The next patch will use this when adding PPC64.
This should cause no behavioural change.
Signed-off-by: Alexey Kardashevskiy <aik@linux.ibm.com>
Diffstat (limited to 'prog')
| -rw-r--r-- | prog/rand.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/prog/rand.go b/prog/rand.go index a115b22ec..85998b942 100644 --- a/prog/rand.go +++ b/prog/rand.go @@ -13,7 +13,8 @@ import ( "strings" "github.com/google/syzkaller/pkg/ifuzz" - _ "github.com/google/syzkaller/pkg/ifuzz/generated" // pull in generated instruction descriptions + "github.com/google/syzkaller/pkg/ifuzz/ifuzzimpl" + _ "github.com/google/syzkaller/pkg/ifuzz/x86/generated" // pull in generated instruction descriptions ) const ( @@ -426,7 +427,7 @@ func (r *randGen) generateText(kind TextKind) []byte { switch kind { case TextTarget: if cfg := createTargetIfuzzConfig(r.target); cfg != nil { - return ifuzz.Generate(cfg, r.Rand) + return ifuzzimpl.Generate(cfg, r.Rand) } fallthrough case TextArm64: @@ -438,7 +439,7 @@ func (r *randGen) generateText(kind TextKind) []byte { return text default: cfg := createIfuzzConfig(kind) - return ifuzz.Generate(cfg, r.Rand) + return ifuzzimpl.Generate(cfg, r.Rand) } } @@ -446,14 +447,14 @@ func (r *randGen) mutateText(kind TextKind, text []byte) []byte { switch kind { case TextTarget: if cfg := createTargetIfuzzConfig(r.target); cfg != nil { - return ifuzz.Mutate(cfg, r.Rand, text) + return ifuzzimpl.Mutate(cfg, r.Rand, text) } fallthrough case TextArm64: return mutateData(r, text, 40, 60) default: cfg := createIfuzzConfig(kind) - return ifuzz.Mutate(cfg, r.Rand, text) + return ifuzzimpl.Mutate(cfg, r.Rand, text) } } @@ -474,8 +475,10 @@ func createTargetIfuzzConfig(target *Target) *ifuzz.Config { switch target.Arch { case "amd64": cfg.Mode = ifuzz.ModeLong64 + cfg.Arch = ifuzz.ArchX86 case "386": cfg.Mode = ifuzz.ModeProt32 + cfg.Arch = ifuzz.ArchX86 default: return nil } @@ -504,12 +507,16 @@ func createIfuzzConfig(kind TextKind) *ifuzz.Config { switch kind { case TextX86Real: cfg.Mode = ifuzz.ModeReal16 + cfg.Arch = ifuzz.ArchX86 case TextX86bit16: cfg.Mode = ifuzz.ModeProt16 + cfg.Arch = ifuzz.ArchX86 case TextX86bit32: cfg.Mode = ifuzz.ModeProt32 + cfg.Arch = ifuzz.ArchX86 case TextX86bit64: cfg.Mode = ifuzz.ModeLong64 + cfg.Arch = ifuzz.ArchX86 default: panic("unknown text kind") } |
